Page 1 of 1

NULL value when returning an array

Posted: Thu Sep 04, 2008 5:10 pm
by ericm
My function queries an oracle database and pulls all corresponding results using the oci_fetch_all function. This function takes several parameters, one of which is a variable to output the data as an array (in my case, given the parameters I've passed in, it's an associative array).

Attempting to return this array, however, gives me a NULL value. I can var_dump the contents of the array and all of the database records are displayed on screen. I read that array parameters can be returned, no problem. Cool, so I want to return this results array (stored in the variable $result). But on the receiving end, I am left with a NULL value.

Code: Select all

 
 
class DB()
{
    function fetch()
    {
        // Get the results from oci_fetch_all.  Results are stored in $results.
        return $results;
    }
}
 
$s = new DB();
$x = $s->fetch("sql query here");
var_dump($x); gettype($x);  // both return NULL
 
 

Re: NULL value when returning an array

Posted: Thu Sep 04, 2008 7:17 pm
by andyhoneycutt

Code: Select all

//This returns a value:
var_dump($s->fetch("sql query here"));
//But this doesn't?
$x = $s->fetch("sql query here");
var_dump($x); gettype($x);  // both return NULL
-Andy

Re: NULL value when returning an array

Posted: Mon Sep 08, 2008 4:17 pm
by ericm
andyhoneycutt wrote:

Code: Select all

//This returns a value:
var_dump($s->fetch("sql query here"));
//But this doesn't?
$x = $s->fetch("sql query here");
var_dump($x); gettype($x);  // both return NULL
-Andy
Found my very stupid mistake...