TP5 find_in_set用法

type 字段在数据库是以 1,2,3 形式存在 已说到FIND_IN_SET函数的使用

对于一些实在复杂的查询,比如find_in_set,也可以直接使用原生SQL语句进行查询,例如:

Db::table('think_user')
    ->where('find_in_set(1,sids)')
    ->select();

为了安全起见,我们可以对字符串查询条件使用参数绑定,例如:

Db::table('think_user')
    ->where('find_in_set(:id,sids)',['id'=>$id])
    ->select();


转载:

http://www.02405.com/program/php/1099.html

猜你喜欢

转载自blog.csdn.net/haibo0668/article/details/80865529