When using OCI_RETURN_LOBS to get a BFILE (stored with a DIRECTORY) the user needs READ on the DIRECTORY. (GRANT READ on DIRECTORY <directory name> TO <user>;) Otherwise, you'll get a cryptic error. Warning: OCILobFileOpen: ORA-22285: non-existent directory or file for FILEOPEN operation in ... on line ...
<BR>
The user that CREATEs the DIRECTORY is automatically GRANTed READ WITH THE GRANT OPTION.
oci_fetch_array
(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
Açıklama
Returns an array, which corresponds to the next result row.
Oci8 sürücüsü tarafından yapılan veri türü eşlemeyle ilgili ayrıntılar için sürücü tarafından desteklenen veri türleri bölümüne bakınız.
It should be mentioned here, that oci_fetch_array() is insignificantly slower, than oci_fetch_row(), but much more handy.
Değiştirgeler
- statement
-
A valid OCI statement identifier.
- mode
-
An optional second parameter can be any combination of the following constants:
- OCI_BOTH - return an array with both associative and numeric indices (the same as OCI_ASSOC + OCI_NUM). This is the default behavior.
- OCI_ASSOC - return an associative array (as oci_fetch_assoc() works).
- OCI_NUM - return a numeric array, (as oci_fetch_row() works).
- OCI_RETURN_NULLS - create empty elements for the NULL fields.
- OCI_RETURN_LOBS - return the value of a LOB of the descriptor.
Default mode is OCI_BOTH.
Dönen Değerler
Returns an array with both associative and numeric indices, or FALSE if there are no more rows in the statement .
Bilginize: Bu işlev NULL alanlara PHP NULL değerini atar.
Bilginize: Oracle returns all field names in uppercase and associative indices in the result array will be uppercased too.
Örnekler
Örnek 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>";
}
?>
Örnek 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
}
?>
Örnek 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"
}
?>
Örnek 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
}
?>
Ayrıca Bakınız
- oci_fetch_assoc() - Returns the next row from the result data as an associative array
- oci_fetch_object() - Returns the next row from the result data as an object
- oci_fetch_row() - Returns the next row from the result data as a numeric array
- oci_fetch_all() - Fetches all rows of result data into an array
oci_fetch_array
09-Aug-2002 07:29
