Chris W. Parker wrote:
Ok I know it's not possible to "return" more than one value. But I'm
going to explain what I'd like to do so maybe there's an easy way to do
it.

I've got some functions that query a database and turn the result into
an array and return that array. What I'd like to do is not only return
the array of results but ALSO return a row count and field count of that
result.

Here is some pseudo code:

function get_results()
{
// query database
        $result = query($sql);
        
// turn result set into a useable array
        $theResultArray = get_results($result);

        $rows = mysql_num_rows($result);
        $fields = mysql_num_fields($result);

        return $theResultArray;
        return $rows;
        return $fields;
}

Ok I know that won't work but that's just basically what I want to do.

The only way around this I've come up with is to stick all the values
into ANOTHER array and return then and then dissect that array in the
calling function, but that just seems messy.

Are you talking about something like this:


$retval['result'] = get_results($result);
$retval['rows'] = mysql_num_rows($result);
$retval['fields'] = mysql_num_fields($result);

return $retval;

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to