After several attempts to find a unique solution for my thought, I’ve had no chances to post this question here in the hope to find someone who can enlight me (if applicable).
I’m working on a “full featured” PHP class with several methods so I will be able to do what I’m willing to do in the future (that is, kinda of personal framework).
I’m stuck in the fetchRow() method of the class. I would like to use this method to fetch rows from a query AND I would like that this method automatically forms the proper data structure.
Now, assuming that I have a query like:
$query = mysql_query("SELECT name, surname FROM people", $dbHandle);
I would like to have this result (if applicable):
/*
* var_dump example results after launching a while statement with
* mysql_fetch_row.
*
* 2 fields (name,surname), 2 "master" arrays with corresponding values
*
*/
array
0 = array( ...names... )
1 = array( ...surnames... )
Now, I tried several native PHP functions, user-defined functions, etc, without goals.
Maybe I’m crazy after these attempts, maybe this is not possible or maybe I can’t see a possible simple way to do that.
How can I do that?
Well you would just do something like:
That said…
ext/mysqlusePDOorMysqli.