mysql 使用order by field() 自定义排序 含thinkphp写法

thinkphp 自定义排序

$map['id'] = '10466,10390';

$data = M('article')->where($map)->field('id,title')->order('field(id,'.$map['id'].')')->select();


mysql 查询

"SELECT `id`,`title` FROM `article` WHERE `id` IN ('10466','10390') ORDER BY field(id,10466,10390)

评论

此博客中的热门博文

PHPMailer配置163邮箱

CDB用户删除数据后,空间不立即释放问题

vue webstrom报错 Expected indentation of 2 spaces but found 4