When using the same query, same user DB credentials, with Toad for Oracle and then with PHP function oci_fetch_assoc, data array returned by oci_fetch_assoc is missing in a few columns, and a few columns are missing alltogether. All expected is present in Toad results.
I googled and searched here, no solution.
Toad is using Instant Client - 11.2.0.1.0
My PHP oci8 information
OCI8 Support - enabled
Version 1.4.6
Revision $Revision: 313688 $
Active Persistent Connections 0
Active Connections 0
Oracle Run-time Client Library Version 11.2.0.2.0
Oracle Instant Client Version 10.2
Temporary Lob support enabled
Collections support enabled
如果您在PHP和Toad中运行完全相同的查询,并且它们返回不同的结果,则唯一的结论是您的PHP忽略了结果集的几列。
When you use oci_fetch_assoc, only the fields with a value that is not NULL will be returned. To work with this I fetch the columnnames with this code:
for ($i=1; $i<=oci_num_fields($parsed); $i++)
{
$col = oci_field_name($parsed, $i);
$columnNames[] = $col; // store column names in array
}
then my fetch function looks something like this:
function fetch()
{
global $columnNames; // (I actually have a Query class so I use $this->columnNames)
$row = oci_fetch_array($parsed, OCI_ASSOC);
foreach ($columnNames as $colname)
$row[$colname] = isset($row[$colname]) ? $row[$colname] : null;
return $row;
}
edit: Another (less likely) possibility is that the missing columns are CLOBS. You need to fetch those with the OCI_RETURN_LOBS flag (see oci_fetch_array )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.