如何使用thinkphp框架實現(xiàn)多個字段排序
2 回答

湖上湖
TA貢獻2003條經驗 獲得超2個贊
thinkphp使用的數(shù)據(jù)庫是mysql,mysql多個字段排序的語句:
select
* from `表名` where 條件 order by 字段1 desc,字段2
asc,...
thinkphp中排序方法為
$User->where('score>0')->order('score desc')....;
但是例子中只能單字段排序,不過可以理解成字符串,那就可以這樣寫試試
$User->where('score>0')->order('score desc,id asc,...')....;
- 2 回答
- 0 關注
- 711 瀏覽
添加回答
舉報
0/150
提交
取消