Find in TP5_ In_ Usage of set

Time:2020-10-16

Tp5.1.22 version

$id=4;
Db::name('menu')->where('FIND_IN_SET(:id,pid_all)',['id' => $id])->update([$field => $title]);

 

$map[]=[‘exp’,’FIND_IN_SET(2,needID)’];

$db->where($map)->select();

 

After tp5.1.21, array query support:

To achieve this query:

1. First, reference: use think / db / where;

2. Definition array: $where = new where;

3. You can use $where [‘title ‘] = [‘like’, “%”. $sotitle. “%”];

$where['class_id'] = ['in', '$cid_all'];
$where['id'] = ['in', $all_ user_ ID]; // or so on
$where['title'] = ['like', '%php%'];
$where['id'] = ['<>', $id];
$where['id'] = ['notin', $all_ user_ ID]; // not equal to
 
 
//The value is a number
$id=419;
$where[] = ['exp',Db::raw("FIND_ IN_ Set ($ID, category) ")]; // category value is a number, example: 419415414
//The value is a string
$ID is equal to DFD. Pay attention to 'quotation marks'
$where[] = ['exp',Db::raw("FIND_ IN_ Set ('$ID', category) ")]; // category value is a number, for example: '349 / 417 / 419','349 / 413 / 415 ','349 / 413 / 416'