14

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

4

3 回答 3

12

MindStalker 是对的,但也许最简单的方法是 PHP 手册中显示的一种方法
http://php.net/manual/en/mysqlinfo.concepts.buffering.php

传递 MYSQLI_USE_RESULT 常量作为resultmode参数,您可以将mysqli_query设置为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();
?>
于 2013-01-10T14:42:07.367 回答
10

mysqli_real_query() 后跟 mysqli_use_result()

于 2009-12-30T19:52:17.040 回答
-4

这个对我有用

$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();
于 2014-03-03T04:56:42.947 回答