感谢答案,我发现我无法使用 fetch_all() 因为我使用的是 PHP 5.2.17 - fetch_assoc> 使用 while 循环工作.
Thanks to the answers I have figured out that I am unable to use fetch_all() because i am using PHP 5.2.17 - fetch_assoc with while loop worked.
我正在使用的函数 fetch_all 返回此错误:
The function I am using fetch_all is coming back with this error:
致命错误:调用未定义的方法mysqli_result::fetch_all()
Fatal error: Call to undefined method mysqli_result::fetch_all() in
$mysqli = new mysqli($host, $username, $password, $database);
$query = "LONG QUERY that works, tested in phpmyadmin"
$result = $mysqli->query($query);
$result->fetch_all(); or $mysqli->fetch_all() tried both
mysqli_fetch_all() was already tried.
$mysqli->close();
我能够连接到数据库并且我已经提取了单行.当我将查询放在 PHPMYADMIN 中时,我得到 5 行.
I am able to connect to the DB and I have pulled single rows. When I place the query in PHPMYADMIN I get 5 rows back.
这个功能还能用吗?有没有办法可以自己将数据放入关联数组中?
Does this function even work? Is there a way I can place my data into an assoc array on my own?
该函数自 PHP 5.3.0 起可用.可能你的版本比较旧.改用 fetch_assoc().
This function is available since PHP 5.3.0. Possibly your version is older. Use fetch_assoc() instead.
while ($row = $result->fetch_assoc()) {
// do what you need.
}
这篇关于mysqli fetch_all() 不是一个有效的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
mysql 中的 store_result() 和 get_result() 返回 falsestore_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
调用未定义的函数 mysqli_result::num_rows()Call to undefined function mysqli_result::num_rows()(调用未定义的函数 mysqli_result::num_rows())
PHP 准备好的语句问题PHP Prepared Statement Problems(PHP 准备好的语句问题)
mysqli_fetch_array 只返回一个结果mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一个结果)
PHP MySQLi 多次插入PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
如何确保 MySQL 中的值在 PHP 中保持其类型?How do I make sure that values from MySQL keep their type in PHP?(如何确保 MySQL 中的值在 PHP 中保持其类型?)