mysql 排序
分享一个技巧
Thhinkphp查询数据库时,按照where in里的顺序排序方法
$id_arr = array(4,1,3,2); $Cond['id'] = array("in", $id_arr);
//这样查询出来的顺序是4,1,3,2
//转化成的SQL语句是SELECT * FROM `table` WHERE ( `id` in ('4','1','3','2') ) order by field(id,4,1,3,2) $data = $DataM->where($Cond)->order("field(id," . implode(',', $id_arr) . ")")->select();