I have a database with a connection and a valid result set from a mysql_query call. In PHP the function mysql_fetch_row($resultSet) returns an array of all the elements in one row.
My question is: Where is the function which returns an array of all elements in all rows?
For instance if my query returns 5 rows of a database I want it to pass back in array with 5 objects (each an array of that rows data)
2006-08-28
12:16:08
·
3 answers
·
asked by
Gehan G
3
in
Computers & Internet
➔ Programming & Design
You would think there is a native function in the mysql class which would do this automaticlly? Why did they leave out this commonly used function?
2006-08-28
12:52:07 ·
update #1
Thanks for the advice jaspal. I've studied the mysql library, and I understand the difference between a numerical and assoc array.
My question concerns the fact that all of those functions return 1 row from the result source.
I want to dump all rows, without having to use a while loop to place them in to an array. Why when I do:
$result = mysql_querty("bla bla",$connection)
print_r($result)
I get back: ResourceID4 or something like that.
I know I can do a while with
print_r(mysql_fetch_row($result) until null
I was hopeing there was some function I was not seeing, or looking over which would pass a complete array of all data returned from the query.
Dream code:
print_r(mysql_fetch_all(mysql_query('bla bla', $connection));
and have it return
Array (
[0] Joe -> [0] Smith -> [1] 342
[1] Mike -> [0] Smith -> [1] 344
[2] Deric ->[0] Scott -> [1] 345
}
2006-08-28
18:39:27 ·
update #2
Apparentlly the function I'm looking for exists so I'm giving the points to the first poster.
2006-08-29
03:49:19 ·
update #3