【发布时间】:2016-11-23 14:26:26
【问题描述】:
尝试在 Laravel 中使用 mysql_fetch_array() 时出现错误。
while ($row = mysql_fetch_array($query))
用什么代替mysql_fetch_array()?
我遇到了错误,
mysql_fetch_array() 期望参数 1 是资源,给定数组
完整部分,
//prepare the tag cloud array for display
$terms = array(); // create empty array
$maximum = 0; // $maximum is the highest counter for a search term
$query = DB::select('SELECT term, counter FROM search ORDER BY counter DESC LIMIT 30');
while ($row = mysql_fetch_array($query))
{
$term = $row['term'];
$counter = $row['counter'];
// update $maximum if this term is more popular than the previous terms
if ($counter > $maximum) $maximum = $counter;
$terms[] = array('term' => $term, 'counter' => $counter);
}
【问题讨论】:
-
添加完整的东西
-
为什么?你为什么要这样做???只需改用
DB函数 -
这里如何使用DB功能? DB::??
标签: php mysql laravel query-builder