使用MySQLi进行无缓冲查询?

时间:2009-12-30 19:38:08

标签: mysql mysqli unbuffered-queries

MySQLi查询是否无缓冲?如果没有,有没有办法进行无缓冲的查询,就像非MySQLi mysql_unbuffered_query()一样?

3 个答案:

答案 0 :(得分:9)

MindStalker是对的,但也许最简单的方法就是PHP手册中显示的那种<{3}}

将MYSQLI_USE_RESULT常量作为 resultmode 参数传递,您可以将http://php.net/manual/en/mysqlinfo.concepts.buffering.php设置为mysqli_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();
?>

答案 1 :(得分:8)

mysqli_real_query()后跟mysqli_use_result()

答案 2 :(得分:-2)

它对我有用

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