【发布时间】:2017-01-18 06:15:01
【问题描述】:
我正在使用 laravel 5.3。我在运行查询时遇到问题。我正在尝试进行 groupby 查询,但它不起作用,并且出现错误,例如调用未定义的方法 Illuminate\Database\Query\Builder::only_full_group_by()。我的代码喜欢
public function showcart()
{
$cart = DB::table('cartshow')->only_full_group_by('pro_id')->get(); die();
$i = 1;
foreach($cart as $tt)
{
$count = DB::table('cartlist')->where('pro_id',$tt->pro_id)->sum('qnty');
$sel_pro= DB::table('product') -> where('id',$tt->pro_id)->first();
$proname = $sel_pro->name;
$price = ($sel_pro->price) * $count;
echo $cartdata ="<tr>
<td>$proname<br><small>Swaminarayan, Extra Hot, Cheese</small></td>
<td style='vertical-align:middle'>
<input type='button' value='-' onclick='qtyminus($tt->pro_id);' class='qtyminus' field='quantity' />
<input type='text' name='quantity' value='$count' class='qty' id='txt$tt->pro_id'/>
<input type='button' value='+' onclick='qtyplus($tt->pro_id);' class='qtyplus' field='quantity' />
</td>
<td class='text-right' style='vertical-align:middle'><button data-id ='$tt->pro_id' type='button' class='btn btn-xs btn-info'><i class='fa fa-remove'></i></button></td>
</tr>";
}
}
【问题讨论】:
-
我在 Laravel 中找不到任何
only_full_group_by方法,我错过了什么吗?您可以发布对您方法的引用吗? -
你不能使用这样的方法。 Laravel QueryBuilder 没有定义该方法。因为,您的链接指向 5.7 版
only_full_group_by是默认的。因此,请改用groupBy()。
标签: laravel laravel-5 laravel-5.2