PHP Doku:: Returns the number of fields contained in a result set - function.db2-num-fields.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenIBM DB2, Cloudscape and Apache DerbyIBM DB2 Funktionendb2_num_fields

Ein Service von Reinhard Neidl - Webprogrammierung.

IBM DB2 Funktionen




(PECL ibm_db2 >= 1.0.0)

db2_num_fields Returns the number of fields contained in a result set


int db2_num_fields ( resource $stmt )

Returns the number of fields contained in a result set. This is most useful for handling the result sets returned by dynamically generated queries, or for result sets returned by stored procedures, where your application cannot otherwise know how to retrieve and use the results.



A valid statement resource containing a result set.


Returns an integer value representing the number of fields in the result set associated with the specified statement resource. Returns FALSE if the statement resource is not a valid input value.


Beispiel #1 Retrieving the number of fields in a result set

The following example demonstrates how to retrieve the number of fields returned in a result set.


"SELECT id, name, breed, weight FROM animals ORDER BY breed";
$stmt db2_prepare($conn$sql);
$columns db2_num_fields($stmt);

"There are {$columns} columns in the result set.";

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

There are 4 columns in the result set.

Siehe auch

Keine BenutzerBeiträge.
- Beiträge aktualisieren...

PHP Powered Diese Seite bei
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)