Dear gods of Stackoverflow
Let's say I have a MySQL query that selects a large dataset:
$query = "SELECT col_1, col_2, ..., col_99 FROM big_table";
And I get a MySQLi result like so:
$result = $db->query($query);
But then instead of dealing with $result in this scope, I pass it to a function:
my_function($result);
And once inside my_function(), I iterate through each row in the result and do stuff:
function my_function($result) {
while($row = $result->fetch_object()) {
...
}
}
Please help me understand the memory implications of this approach.
In other words, what does $result contain, and are there any pitfalls with passing it to a function? Should I consider passing $result by reference instead? For what it's worth, I won't be needing $result once my_function() is done with it.
Cheers from South Africa!