php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35344 oci_fetch_assoc or oci_fetch_array returns nothing, but oci_fetch_all works OK
Submitted: 2005-11-23 07:19 UTC Modified: 2005-11-24 13:28 UTC
From: sdb at mail dot chita dot ru Assigned:
Status: Not a bug Package: OCI8 related
PHP Version: 5.0.5 OS: Red Hat Enterprise Linux AS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sdb at mail dot chita dot ru
New email:
PHP Version: OS:

 

 [2005-11-23 07:19 UTC] sdb at mail dot chita dot ru
Description:
------------
My script successfully connects to oracle, parse and execute simple query (select * from some_table).

Functions oci_fetch_assoc, oci_fetch_array, oci_fetch_row does not return an array. When I try to do "each" with returned array, PHP prints "Variable passed to each() is not an array or object"

oci_num_fields returns right count of columns in result and oci_field_name returns right column names in loop.

Function oci_fetch_all works good, it returns result (array of fields and values), that I expect.



Reproduce code:
---------------
$c=oci_new_connect("a", "b" , "c", "AMERICAN_AMERICA.CL8MSWIN1251");
$s = oci_parse($c, "SELECT NAME from ABONENT");
if (oci_execute($s, OCI_DEFAULT))
{
    while($a=oci_fetch_assoc($s))    {
	while (list($key, $val) = each($a))
	{
	    echo $key." = ".$val."<br>";
	};
    };
};


Expected result:
----------------
Something like that:
NAME = aaa
NAME = bbb
...

Actual result:
--------------
Warning: Variable passed to each() is not an array or object in /var/www/test3.php on line 27


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-23 09:18 UTC] sniper@php.net
Try doing 'var_dump($a);' 
 [2005-11-24 06:22 UTC] sdb at mail dot chita dot ru
The result of var_dump($a) is: "bool(false)"
 [2005-11-24 09:24 UTC] sniper@php.net
"A subsequent call to oci_fetch_assoc() will return the next row or FALSE if there are no more rows."
 [2005-11-24 09:36 UTC] sdb at mail dot chita dot ru
OK
 [2005-11-24 13:28 UTC] tony2001@php.net
.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 24 00:00:03 2025 UTC