(PHP 5, PECL oci8 >= 1.1.0)
oci_fetch_array — Returns the next row from the result data as an associative or numeric array, or both
Returns an array, which corresponds to the next result row.
oci8 드라이버에서 수행하는 자료형 매핑에 대한 상세는 드라이버가 지원하는 자료형을 참고하십시오.
It should be mentioned here, that oci_fetch_array() is insignificantly slower, than oci_fetch_row(), but much more handy.
A valid OCI statement identifier.
An optional second parameter can be any combination of the following constants:
Default mode is OCI_BOTH.
Returns an array with both associative and numeric indices, or FALSE if there are no more rows in the statement .
Note: 이 함수는 NULL 필드를 PHP NULL 값으로 설정합니다.
Note: Oracle returns all field names in uppercase and associative indices in the result array will be uppercased too.
Example #1 oci_fetch_array() with OCI_BOTH example
<?php
$connection = oci_connect("apelsin", "kanistra");
$query = "SELECT id, name FROM fruits";
$statement = oci_parse ($connection, $query);
oci_execute ($statement);
while ($row = oci_fetch_array ($statement, OCI_BOTH)) {
echo $row[0]." and ".$row['ID']." is the same<br>";
echo $row[1]." and ".$row['NAME']." is the same<br>";
}
?>
Example #2 oci_fetch_array() with OCI_NUM example
<?php
$connection = oci_connect("user", "password");
$query = "SELECT id, name, lob_field FROM fruits";
$statement = oci_parse ($connection, $query);
oci_execute ($statement);
while ($row = oci_fetch_array ($statement, OCI_NUM)) {
echo $row[0]."<br>";
echo $row[1]."<br>";
echo $row[2]->read(100)."<br>"; //this will output first 100 bytes from LOB
}
?>
Example #3 oci_fetch_array() with OCI_ASSOC example
<?php
$connection = oci_connect("user", "password");
$query = "SELECT id, name, lob_field FROM fruits";
$statement = oci_parse ($connection, $query);
oci_execute ($statement);
while ($row = oci_fetch_array ($statement, OCI_ASSOC)) {
echo $row['ID']."<br>";
echo $row['NAME']."<br>";
echo $row['LOB_FIELD']."<br>"; //this will output "Object id #1"
}
?>
Example #4 oci_fetch_array() with OCI_RETURN_LOBS example
<?php
$connection = oci_connect("user", "password");
$query = "SELECT id, name, lob_field FROM fruits";
$statement = oci_parse ($connection, $query);
oci_execute ($statement);
while ($row = oci_fetch_array ($statement, (OCI_NUM+OCI_RETURN_LOBS))) {
echo $row[0]."<br>";
echo $row[1]."<br>";
echo $row['LOB_FIELD']."<br>"; //this will output LOB's content
}
?>