【发布时间】:2015-08-03 16:11:22
【问题描述】:
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 构建的新网站,并且此错误一直出现,我不知道如何修复它。
致命错误:调用未定义的方法 CI_DB_mysqli_result::fetch()
任何帮助将不胜感激..
【问题讨论】:
标签: php sql codeigniter mysqli smarty