ThinkCMF multi-condition query sql where condition judgment
The format of the Where conditional expression in TP is:
$map['field name'] = array('expression','operating conditions');
$map['status'] = array('=', '1');
$map['title'] = array('like', '%测试%');
$map['delete_time'] = array('=', '0');
Actually, I don’t know why it becomes
where `status` in ('=', '1') and `title` in ('like', '%测试%') and `delete_time` in ('=', '0')
In desperation, change the wording:
$map = array();
$map[] = ['post_status', '=', 1];
$map[] = ['delete_time', '=', 0];
if ( $word != '' ){
$map[] = ['post_title', 'like', '%'.$word.'%'];
}
This is the result I want
Db::name('recruit')
->where($map)
->order('is_top DESC')
->order('published_time DESC')
->paginate(20);