i am already aware of what and how to use fetch_array, fetch_assoc, fetch_row, fetch_object, and fetch_all(MYSQLI_NUM or MYSQLI_ASSOC or MYSQLI_BOTH).
but i just discovered and experimented that this code below worked for me, without using any fetch_* objects.
$sqli = $db->query("SELECT * FROM `tblSample`;");
foreach($sqli as $out) {
echo "val1 => ", $out['0'], "<br />val2 => ", $out['1'], "<br />val3 => ", $out['2'];
}
as you can see, i wasn't using any fetch_ objects or so and for some reason, by using the foreach loop, i was still able to fetch the results of the query.
i tried doing so with while loop as how it worked with the foreach loop, but to no avail.
so i just wanted to ask, since i know that some other professional developers out there might've already encountered this way.
IS THIS RECOMMENDED ?. given that there was no fetch_ objects used ?. thank you