如何使用thinkphp框架實現多個字段排序
1 回答

HUWWW
TA貢獻1874條經驗 獲得超12個贊
thinkphp使用的數據庫是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,...')....;
- 1 回答
- 0 關注
- 806 瀏覽
添加回答
舉報
0/150
提交
取消