早睡早起,方能养生
Sleep early rise early, way to keep healthy

ThinkPHP5.1 SQL语句使用多个like

super
2020-10-21 18:11
views 4694

$map = [];

$value1 = 1;
$value2 = 2;
$value3 = 3;

$map[] = [
    'field_name',  // 字段
    ['like', '%' . $value1 . '%'], // like 1
    ['like', '%' . $value2 . '%'], // like 2
    ['like', '%' . $value3 . '%'], // like 3
    // like ...
    'or'
];

Db::name('tb_name')->where($map)->find();


分享
0 条讨论
top