PHP 8.6.0 Beta 1 is available for testing

oci_num_fields

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

oci_num_fieldsDevuelve el número de columnas en un resultado Oracle

Descripción

function oci_num_fields(resource $statement): int

Devuelve el número de columnas en el resultado Oracle statement.

Parámetros

statement

Un identificador de consulta OCI válido.

Valores devueltos

Devuelve el número de columnas, en forma de int .

Ejemplos

Ejemplo #1 Ejemplo con oci_num_fields()

<?php
// Creación de la tabla con:
// 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); // Uso de OCI_DESCRIBE_ONLY si no se recupera ninguna fila
$ncols = oci_num_fields($stid);
for ($i = 1; $i <= $ncols; $i++) {
 echo oci_field_name($stid, $i) . " " . oci_field_type($stid, $i) . "<br>\n";
}
// Muestra:
// ID NUMBER
// QUANTITY NUMBER
oci_free_statement($stid);
oci_close($conn);
?>

Found A Problem?

Learn How To Improve This PageSubmit a Pull RequestReport a Bug
+add a note

User Contributed Notes 1 note

up
1
jnield at impole dot com
26 years ago
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.
+add a note

AltStyle によって変換されたページ (->オリジナル) /