TP5中find_in_set的用法


TP5.1.22版本

$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();

 

TP5.1.21   版本之后數組查詢支持:

要達到這樣子查詢:

1、首先引用: use think\db\Where;

2、定義數組:$where = new Where;

3、就可以用了:$where['title'] = ['like', "%".$sotitle."%"];

$where['class_id'] = ['in', '$cid_all'];
$where['id'] = ['in', $all_user_id];//或這樣子
$where['title'] = ['like', '%php%'];
$where['id'] = ['<>', $id];
$where['id'] = ['notin', $all_user_id];//不等於
 
 
//值為數字
$id=419;
$where[] = ['exp',Db::raw("FIND_IN_SET($id,category)")];//category值為數字,例子:419,415,414
//值為字符串
$id值等於dfd 要注意'引號
$where[] = ['exp',Db::raw("FIND_IN_SET('$id',category)")];//category值為數字,例子:'349/417/419','349/413/415','349/413/416'


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM