mercredi 19 octobre 2016

Laravel 5.3 “group by count” query issues

Please I am trying to run a query that looks like this in raw sql

SELECT `qnty`, COUNT(*) FROM cartlist GROUP BY `pro_id`,`cart_id`,`price`

in laravel.

I have tried this

$count = DB::table('cartlist')
                 ->select(DB::raw('count(*) as qnty'))
                 ->where('pro_id', '$tt->pro_id')
                 ->where('cart_id', '$cart_id')
                 ->groupBy('pro_id','price')
                 ->get();

But it gives the following error

Object of class Illuminate\Support\Collection could not be converted to int



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire