On Wed, 2003-11-05 at 19:02, Chris W. Parker wrote:
> Hi list.
>
> 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;
> }
>
You can do the following:
function get_results( &$rows, &$fields )
{
// 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;
}
HTH,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php