对于PHP的缓冲模式查询大家都知道,下面列举的例子是如何执行非缓冲查询API。
非缓冲查询方法一:
MysqLiPHP;">
query("SELECT Name FROM City",MysqLI_USE_RESULT);
if ($uresult) {
while ($row = $uresult->fetch_assoc()) {
echo $row['Name'] . PHP_EOL;
}
}
$uresult->close();
?>
非缓冲查询方法二:
pdo_MysqLPHP;">
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;">
$uresult = mysql_unbuffered_query("SELECT Name FROM City");
if ($uresult) {
while ($row = mysql_fetch_assoc($uresult)) {
echo $row['Name'] . PHP_EOL;
}
}
?>
if ($uresult) {
while ($row = mysql_fetch_assoc($uresult)) {
echo $row['Name'] . PHP_EOL;
}
}
?>