order排序

Db::table('think_user')
->where('status', 1)
->order('id', 'desc')
->limit(5)
->select();

使用数组对多个字段的排序

Db::table('think_user')
->where('status', 1)
->order(['order','id'=>'desc'])
->limit(5)
->select(); 

使用mysql函数

Db::table('think_user')
->where('status', 1)
->orderRaw("field(name,'thinkphp','onethink','kancloud')")
->limit(5)
->select();

自定义排序

$arr = "12,10,11";
orderRaw("find_in_set(product_start_stie,'".$arr."')")

相关文章:

  • 2022-01-13
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2021-10-19
  • 2021-09-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
相关资源
相似解决方案