MySQLi仅显示一个结果
问题描述:
我有一个简单的问题,我的MySQLi函数在var_dump中只显示一行/结果:
I have a simple problem, that my MySQLi function only shows one row / result in var_dump:
$sql = $db->query('SELECT * FROM '.$db_prefix.'_posts');
$row = $sql->fetch_array();
var_dump($row);
就是这样. phpMyAdmin中的查询显示3个结果.仅此一个1.它也不适用于fetch_assoc()或fetch_array().
That's it. The query in phpMyAdmin shows 3 results. This one only 1. It also doesn't work with fetch_assoc() or fetch_array().
另外,我想列出与"fetch_array()"相同的表的键.
Also, I want to have the keys of the table being listed as with "fetch_array()".
答
尝试一会儿循环:
while($row = $sql->fetch_row())
{
var_dump($row);
}
因为fetch_row()
,fetch_array()
,fetch_assoc()
在每次被调用时都会返回一行,直到它超出行数"为止.
Because fetch_row()
, fetch_array()
, fetch_assoc()
will all return one row every singe time it's being called untill it is 'out of rows'.