Using the PHP Function oci_num_fields()
A function is a block of code that can be called repeatedly throughout an application. Functions can return information back to the calling program via a value or can execute a specific task. PHP supports more than 1000 built-in functions for doing just about anything you can imagine, but it is also possible to create custom function modules that perform a particular job.
When a statement in an Oracle database is parsed, it will be stored locally in the PHP session until it is either executed or committed to the database (by another transaction). Changed data is only visible within your current database session until it is either explicitly committed or rolled back by a call to oci_commit().
oci_num_fields() is a utility function that returns the number of columns in a given SQL statement. This information is useful for applications that bind values to parameters and execute the statement with oci_fetch_array() or oci_new_cursor().
This function requires a parameter handle, returned by oci_parse() or created with oci_new_cursor(), as well as the statement to be executed. The return value is an integer representing the number of rows affected by the statement.
This is the most commonly used function in PHP that uses oci_fetch_array(). It is important to know the number of rows affected by a query in order to optimize the performance of your web application. In addition to reducing the amount of SQL statements that are sent to the Oracle database, this function can greatly improve application performance by allowing you to prefetch rows.