Are MySQLi queries unbuffered? If not, is there a way to do an unbuffered query, as with the non-MySQLi mysql_unbuffered_query()
?
Unbuffered queries can also be referred to as "use result". Following these characteristics buffered queries should be used in cases where you expect only a limited result set or need to know the amount of returned rows before reading all rows. Unbuffered mode should be used when you expect larger results.
Unbuffered MySQL queries execute the query and then return a resource that points to the result set. This uses less memory, and allows MySQL to continue executing the query as the result set is used. It also increases load on the server.
Definition and Usage The query() / mysqli_query() function performs a query against a database.
Return Values ¶ For successful queries which produce a result set, such as SELECT, SHOW, DESCRIBE or EXPLAIN , mysqli_query() will return a mysqli_result object. For other successful queries, mysqli_query() will return true .
MindStalker is right but maybe the easiest way is the one shown in the PHP manual
http://php.net/manual/en/mysqlinfo.concepts.buffering.php
Passing the MYSQLI_USE_RESULT constant as the resultmode argument, you can set mysqli_query to work as mysql_unbuffered_query
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$uresult = $mysqli->query("SELECT Name FROM City", MYSQLI_USE_RESULT);
if ($uresult) {
while ($row = $uresult->fetch_assoc()) {
echo $row['Name'] . PHP_EOL;
}
}
$uresult->close();
?>
mysqli_real_query() followed by mysqli_use_result()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With