array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'function.oci-num-fields.php', 1 => 'oci_num_fields', 2 => 'Returns the number of result columns in a statement', ), 'up' => array ( 0 => 'ref.oci8.php', 1 => 'OCI8 Funktionen', ), 'prev' => array ( 0 => 'function.oci-new-descriptor.php', 1 => 'oci_new_descriptor', ), 'next' => array ( 0 => 'function.oci-num-rows.php', 1 => 'oci_num_rows', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/oci8/functions/oci-num-fields.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

oci_num_fields

(PHP 5, PHP 7, PHP 8, PECL OCI8 >= 1.1.0)

oci_num_fieldsReturns the number of result columns in a statement

Beschreibung

oci_num_fields(resource $statement): int

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 int.

Beispiele

Beispiel #1 oci_num_fields() example

<?php

// Create the table with:
// CREATE TABLE mytab (id NUMBER, quantity NUMBER);

$conn = oci_connect("hr", "hrpwd", "localhost/XE");
if (!
$conn) {
$m = oci_error();
trigger_error(htmlentities($m['message']), E_USER_ERROR);
}

$stid = oci_parse($conn, "SELECT * FROM mytab");
oci_execute($stid, OCI_DESCRIBE_ONLY); // Use OCI_DESCRIBE_ONLY if not fetching rows

$ncols = oci_num_fields($stid);
for (
$i = 1; $i <= $ncols; $i++) {
echo
oci_field_name($stid, $i) . " " . oci_field_type($stid, $i) . "<br>\n";
}

// Outputs:
// ID NUMBER
// QUANTITY NUMBER

oci_free_statement($stid);
oci_close($conn);

?>