$this->db->order("position desc")->paginate(2);
一个排序功能,根据某字段的大小值排序,发现order失效;
原因如下:
object(think\paginator\driver\Bootstrap)#20 (9) { ["simple":protected] => bool(false) ["items":protected] => object(think\Collection)#19 (1) { ["items":protected] => array(2) { [0] => array(8) { ["id"] => int(7) ["classify"] => string(6) "测试1" ["quantity"] => string(1) "0" ["state"] => string(1) "1" ["uptime"] => string(10) "1663983778" ["time"] => string(10) "1663983778" ["operator"] => string(5) "admin" ["position"] => string(2) "12" } [1] => array(8) { ["id"] => int(1) ["classify"] => string(6) "测试2" ["quantity"] => string(1) "0" ["state"] => string(1) "1" ["uptime"] => string(10) "1663899645" ["time"] => string(10) "1663899645" ["operator"] => string(5) "admin" ["position"] => string(4) "1000" } } } } //根据['position']排序的 输出显示order并未生效 字段类型为 string //把['position']字段的数据类型修改为 int 排序生效标签:10,string,thinkphp,position,array,排序,order From: https://www.cnblogs.com/caopeng/p/16725921.html