Fatal error: Call to undefined method CI_DB_mysqli_result::fetch()
Fatal error: Call to undefined method CI_DB_mysqli_result::fetch()
public function getVoters($limit = 5)
{
$db = $this->load->database("cms", true);
$year = date('Y');
$month = date('n');
$res = $this->db->query("SELECT account, counter FROM votecounter WHERE year=$year AND month=$month ORDER BY counter DESC LIMIT 5");
$x = 1;
while ($arr = $res->fetch())
{
$accid = $arr['account'];
$res2 = $DB->prepare("SELECT `displayName` FROM `account_data` WHERE `id` = :acc LIMIT 1;");
$res2->bindParam(':acc', $accid, PDO::PARAM_STR);
$res2->execute();
$arr2 = $res2->fetch();
echo '
<li>
<p>', $x ,'</p>
<a href="', $config['BaseURL'], '/index.php?page=profile&uid=', $accid, '">', $arr2['displayName'] ,'</a>
<span>', $arr['counter'] ,' <i>Votes</i></span>
</li>';
$x++;
unset($res2, $arr2, $accid);
}
unset($res, $x);
}
这曾经在我拥有的 PHP 网站上工作,但是我更改为使用 Smarty/Codeigniter 构建的新网站并且此错误一直出现,我不知道如何修复它.
Fatal error: Call to undefined method CI_DB_mysqli_result::fetch()
任何帮助将不胜感激..
如果我没有记错的话,codeigniter 中没有 fetch()
函数。
所以也许可以使用 result_array()
。
public function getVoters($limit = 5)
{
$db = $this->load->database("cms", true);
$year = date('Y');
$month = date('n');
$res = $this->db->query("SELECT account, counter FROM votecounter WHERE year=$year AND month=$month ORDER BY counter DESC LIMIT 5");
$x = 1;
while ($arr = $res->fetch())
{
$accid = $arr['account'];
$res2 = $DB->prepare("SELECT `displayName` FROM `account_data` WHERE `id` = :acc LIMIT 1;");
$res2->bindParam(':acc', $accid, PDO::PARAM_STR);
$res2->execute();
$arr2 = $res2->fetch();
echo '
<li>
<p>', $x ,'</p>
<a href="', $config['BaseURL'], '/index.php?page=profile&uid=', $accid, '">', $arr2['displayName'] ,'</a>
<span>', $arr['counter'] ,' <i>Votes</i></span>
</li>';
$x++;
unset($res2, $arr2, $accid);
}
unset($res, $x);
}
这曾经在我拥有的 PHP 网站上工作,但是我更改为使用 Smarty/Codeigniter 构建的新网站并且此错误一直出现,我不知道如何修复它.
Fatal error: Call to undefined method CI_DB_mysqli_result::fetch()
任何帮助将不胜感激..
如果我没有记错的话,codeigniter 中没有 fetch()
函数。
所以也许可以使用 result_array()
。