PHP Doku:: Returns the number of result columns in a statement - function.oci-num-fields.html

Verlauf / Chronik / History: (26) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenOracle OCI8OCI8 Funktionenoci_num_fields

Ein Service von Reinhard Neidl - Webprogrammierung.

OCI8 Funktionen

<<oci_new_descriptor

oci_num_rows>>

oci_num_fields

(PHP 5, PECL OCI8 >= 1.1.0)

oci_num_fieldsReturns the number of result columns in a statement

Beschreibung

int oci_num_fields ( resource $statement )

Gets the number of columns in the given statement.

Parameter-Liste

statement

A valid OCI statement identifier.

Rückgabewerte

Returns the number of columns as an integer, or FALSE on errors.

Beispiele

Beispiel #1 oci_num_fields() example

<?php
$conn 
oci_connect("scott""tiger");
$stmt oci_parse($conn"select * from emp");

oci_execute($stmt);

while (
oci_fetch($stmt)) {
    echo 
"\n";
    
$ncols oci_num_fields($stmt);
    for (
$i 1$i <= $ncols$i++) {
        
$column_name  oci_field_name($stmt$i);
        
$column_value oci_result($stmt$i);
        echo 
$column_name ': ' $column_value "\n";
    }
    echo 
"\n";
}

oci_free_statement($stmt);
oci_close($conn);
?>

Anmerkungen

Hinweis:

In PHP versions before 5.0.0 you must use ocinumcols() instead. This name still can be used, it was left as alias of oci_num_fields() for downwards compatability. This, however, is deprecated and not recommended.


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
jnield at impole dot com
19.11.1999 4:43
The following is not immediately obvious:

If you need the number of columns in a REF CURSOR returned from a PL/SQL procedure, you need to use OCINumColumns() on the cursor handle returned by OCINewCursor after it is bound and executed, not the statement handle. Same applies for OCIColumnName() and friends.



PHP Powered Diese Seite bei php.net
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",...)