首页 > 代码库 > SQL LIKE操作符 Thinkphp

SQL LIKE操作符 Thinkphp

LIKE 操作符用于在 WHERE 子句中搜索列中的指定模式。

SELECT * FROM calendar_events WHERE userIds LIKE %,5,% OR userIds LIKE 5,% OR userIds LIKE 5

Thinkphp中,

$infoWhere[‘userIds‘] = array(‘like‘,array(‘%,‘.$cur_id,‘%,‘.$cur_id.‘,%‘,$cur_id.‘,%‘,$cur_id),‘OR‘);
$events = M(‘calendar_events‘);
 $list = $events
      ->where( $infoWhere)
      ->field(‘id,text,start_date,end_date,details,subject,userIds‘)
      ->order(‘start_date ‘)
      ->select();

 

SQL LIKE操作符 Thinkphp