MySQLi 的无缓冲查询?

发布于 2024-08-17 03:25:26 字数 93 浏览 4 评论 0原文

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情仇皆在手 2024-08-24 03:25:26

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

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();
?>
野侃 2024-08-24 03:25:26

mysqli_real_query() 后跟 mysqli_use_result()

mysqli_real_query() followed by mysqli_use_result()

苍风燃霜 2024-08-24 03:25:26

这对我有用

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

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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文