In an associative array there is no table prefix for the column name. If you join tables where
the same column name occurs with different meanings in both tables, use a column alias in
the query. Otherwise only one of the similarly named columns will be returned by PHP:
Note: Numbers and dates are fetched as strings and the Oracle globalization settings may affect their formatting.
Refer to the chapter Globalization for more information.
Some of the fetch functions do not return NULL data by default. This can be tricky when using
numerically indexed arrays. The result array can appear to have fewer columns than selected,
and you can’t always tell which column was NULL. Either use associative arrays so the
column names are directly associated with their values, or specify the OCI_RETURN_NULLS
flag:
$res = oci_fetch_array($s, OCI_NUM+OCI_RETURN_NULLS);
<?
$c = oci_connect("hr", "hrpwd", "//localhost/XE");
$s = oci_parse($c, "select region_name,
regions.region_id as myreg,
country_name,
countries.region_id
from countries
inner join regions
on countries.region_id = regions.region_id");
oci_execute($s);
while ($res = oci_fetch_array($s)) {
echo $res["REGION_NAME"] . " " . $res["MYREG"] . " - " .
$res["COUNTRY_NAME"] . " " . $res["REGION_ID"] . " " .
"<br>\n";
}
?>
The query column alias MYREG is used as the index to the result array. The script output is:
Americas 2 - Argentina 2
Asia 3 - Australia 3
Europe 1 - Belgium 1
Americas 2 - Brazil 2
Americas 2 - Canada 2