我试图运行以下Query with Query构建器。
table1(date, curr_book_bal)
但我得到了以下错误。
我更改了$products = \DB::table('users')
->join('products','products.auth_id','users.id')
->leftjoin('buys','products.id','buys.product_id')
->select('products.*','users.avatar',DB::raw('COUNT(buys.product_id) as total_sells') )
->groupBy('products.id')
->where('products.status','=','1')
->take(20)
->paginate(4);
Where in products.id could be there in buys table or not..
。
database.php mysql array from strict = true to false
答案 0 :(得分:0)
尝试
$products = \DB::table('users')
->selectRaw('products.*,users.avatar, COUNT(buys.product_id) as total_sells')
->where('products.status','=','1')
->join('products','products.auth_id','=', 'users.id')
->leftjoin('buys','products.id','buys.product_id')
->groupBy('products.id')
->take(20)
->get();
我不确定paginate是否可以查询构建器。