PHP and database links I checked the DISCUZ database tool class
I have a question:
Function dql ($ SQL)
{
$ Res = $ this-> mysqli-> query ($ SQL );
If (! Empty ($ res ))
{
$ Arr = array ();
While ($ row = $ res-> fetch_row ())
{$ Arr [] = $ row ;}
Return $ arr;
$ Res-> free_result ();
} Else
{Return null ;}
It turns the data obtained from the database into an array $ ROW and stores $ row to $ arr. then, it returns a two-dimensional array.
Why not a $ row is returned directly? Why two more packages?
Reply to discussion (solution)
Returns a $ row. how do you get all records.
If only $ row is returned, only the last row is obtained.
A two-dimensional array is returned, and multiple data entries in the table structure are returned.
$ Row is a record. if it is not encapsulated into a two-dimensional array, you will always get a record, even if you loop it into a record (the last record in the table ).
To obtain more records, we need to put the one-dimensional array into the two-dimensional array so that the previous data will not be overwritten during the loop so that the data will be taken out.
$ Row every time? Take one ???, So we need to follow? Go? .