对于php的缓冲模式查询大家都知道,下面列举的例子是如何执行非缓冲查询api。
非缓冲查询方法一: mysqli
<?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();
?>
非缓冲查询方法二: pdo_mysql
<?php
$pdo = new pdo("mysql:host=localhost;dbname=world", 'my_user', 'my_pass');
$pdo->setattribute(pdo::mysql_attr_use_buffered_query, false);
$uresult = $pdo->query("select name from city");
if ($uresult) {
while ($row = $uresult->fetch(pdo::fetch_assoc)) {
echo $row['name'] . php_eol;
}
}
?>
非缓冲查询方法三: mysql
<?php
$conn = mysql_connect("localhost", "my_user", "my_pass");
$db = mysql_select_db("world");
$uresult = mysql_unbuffered_query("select name from city");
if ($uresult) {
while ($row = mysql_fetch_assoc($uresult)) {
echo $row['name'] . php_eol;
}
}
?>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持硕编程。
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!