Mysql database to two dimetnional array

so i know how to grab a row from a mysql database with mysql_fetch_array, but how do i turn the whole database into a two dimentional array so i can close the connection and just work with my array?

Personally i wouldn’t recommend dumping your entire database into just one array, depending on the size of the database and the number of entries in each table the MySQL server could timeout before it even finishes retrieving the data.

A better option would be to break it down into chunks by using a class or procedural functions to retrieve the data when its needed as more then likely you won’t use every bit of data straight away.

PDO and mySQLi can do it – for PDO it’s PDOStatement::fetchAll and for mySQLi it’s mysqli_result::fetch_all

The outdated insecure old mySQL_ functions – Not so much… There’s a reason they should have gone the way of the dodo five years ago, and the only reason they’re still around today is legacy code and web-rot tutorials.

Though as SgtLegend suggested in his reply, from a memory use standpoint it’s often a REALLY bad idea to pull all the data at once that way. Not sure why you’re so hard-set on closing the connection – though a result statement I thought worked AFTER you disconnected anyways as that’s a PHP construct, not a SQL one. Might be mistaken on that though. I thought as long as you don’t release your $result variable, it would still work connection or no.

But then it’s been years since I used the old mySQL_ functions.

thanks bro, works great!