Here's a simple example of using the oci_fetch_assoc function for anyone who would like to see it.
<?php
$oconn = oci_connect('ora_user','ora_pass','ora_inst');
if (!$oconn){
$msg = "Cannot connect to Oracle ".oci_error();
} else {
$msg = "Connected to Oracle";
}
$select_stmt = "select username from user_table";
$stid = oci_parse($oconn, $select_stmt);
oci_execute($stid);
echo "<table border='1'>\n";
while ($row = oci_fetch_assoc($stid)) {
echo "<tr>\n";
echo "<td>". $row["USERNAME"] . "</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
oci_free_statement($stid);
oci_close($oconn);
?>
Make sure you capitalize the column name for referencing the item in the associative array. Of course, this is just a simple example and you might want to do some processing on the data prior to output, but you get the idea here.
oci_fetch_assoc
(PHP 5, PECL oci8 >= 1.1.0)
oci_fetch_assoc — Returns the next row from the result data as an associative array
Описание
Returns the next row from the result data as an associative array.
Calling oci_fetch_assoc() is identical to calling oci_fetch_array() with OCI_ASSOC.
A subsequent call to oci_fetch_assoc() will return the next row or FALSE if there are no more rows.
За повече информация относно свързването на типове данни, което се извършва от oci8 драйвера, вижте типовете данни поддържани от драйвера
Параметри
- statement
-
A valid OCI statement identifier.
Връщани стойности
Returns an associative array, or FALSE if there are no more rows in the statement .
Забележка: Тази функция установява NULL полетата със стойността null; в PHP.
Забележка: Oracle returns all field names in uppercase and associative indices in the result array will be uppercased too.
Вж. също
- oci_fetch_array() - Returns the next row from the result data as an associative or numeric array, or both
- 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
