unbuffered query with MySQLi?

拜拜、爱过 提交于 2019-12-19 13:49:06

问题


Are MySQLi queries unbuffered? If not, is there a way to do an unbuffered query, as with the non-MySQLi mysql_unbuffered_query()?


回答1:


mysqli_real_query() followed by mysqli_use_result()




回答2:


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();
?>



回答3:


it works for me

$uresult = $mysqli_new->query("INSERT INTO world (username, userid, points, price, br, admin) 
VALUES ('$word[username]',$word[userid], $points, 0, 0, '$word[adminname]')", MYSQLI_USE_RESULT);
$uresult = $mysqli_new->query("SELECT username FROM world WHERE userid='$word[userid]'", MYSQLI_USE_RESULT);
if ($uresult) 
{
    while ($row = $uresult->fetch_assoc()) 
    {
       echo "uresult: ".$row['username'] . PHP_EOL;
    }
}
$uresult->close();


来源:https://stackoverflow.com/questions/1982016/unbuffered-query-with-mysqli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!