oci_num_fields

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

oci_num_fields — 명령문의 결과 열 수를 반환합니다.


설명

oci_num_fields(resource $statement): int

주어진 statement의 열 수를 가져옵니다.


매개변수

statement
유효한 OCI 문 식별자입니다.

반환 값

열 수를 int로 반환합니다.


Examples

예제 #1 oci_num_fields() 예제

                  
<?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);

?>
                    
                  

노트

메모: PHP 5.0.0 이전 버전에서는 대신 ocinumcols()을 사용해야 합니다. 이 이름은 여전히 ​​사용할 수 있으며 하위 호환성을 위해 oci_num_fields()의 별칭으로 남겨졌습니다. 그러나 이것은 더 이상 사용되지 않으며 권장되지 않습니다.