A beginner's question about while function dql ($ SQL)
{
$ Res = $ this-> mysqli-> query ($ SQL );
If (! Empty ($ res ))
{
While ($ row = $ res-> fetch_row ())
Return $ row;
$ Res-> free_result ();
} Else
{Return null ;}
}
I don't understand why he only returns one statement? There are many results in the query. if The while clause is true, it returns a statement. Why does it only return the last statement?
$ A = 20;
While ($ a <= 30)
{Echo $;
$ A ++}
?>
What is the difference between the above and $ row? It is not the first time to judge in the output, and then to judge in the output? The output will not be made until the condition is invalid. Why is $ row output only once? The condition of $ row is that $ res has no record, so it does not loop .. Is it true that I understand while?
I have always understood that as long as the while condition is true, a code block will be cycled once. it seems that the code block is output after all loops in $ row?
Reply to discussion (solution)
At least your observations are not very careful.
While ($ row = $ res-> fetch_row ())
Return $ row;
Only the first record is returned, not other