I'm trying to get all my items from item table ordering by product id, desc or asc.
Query :
public function getAllItems($brandid)
{
$data=DB::table('items')->where('brandid',$brandid)
->orderBy('productid' , 'desc')
->get();
return $data;
}
Data appears with no order by product id, orderBy is not working. Where is the problem ?
Ok, problem solved, I had 2 functions with the same name, my mistake. Thank you
To check your query statement to confirm the problem with your query builder:
DB::enableQueryLog();
$data=DB::table('items')->where('brandid',$brandid)
->orderBy('productid' , 'desc')
->get();
dd(DB::getQueryLog());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.