Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel查询生成器:MySQL';比如';在多个where条件查询中_Php_Sql_Laravel 5.2 - Fatal编程技术网

Php Laravel查询生成器:MySQL';比如';在多个where条件查询中

Php Laravel查询生成器:MySQL';比如';在多个where条件查询中,php,sql,laravel-5.2,Php,Sql,Laravel 5.2,我正在尝试执行一个查询,其中我有多个条件(包括%LIKE%运算符),但不知道如何使用查询生成器以Laravel的数组方式执行 $where = ['category' => $c->id, 'name' => $c->name]; $q = Store::where($where)->get(); 这样,它将返回一个与名称相等的对象数组,而不是类似的匹配项。可以用这种方式进行%LIKE%搜索吗?您应该这样链接它们: DB::table('your-table-na

我正在尝试执行一个查询,其中我有多个条件(包括%LIKE%运算符),但不知道如何使用查询生成器以Laravel的数组方式执行

$where = ['category' => $c->id, 'name' => $c->name];
$q = Store::where($where)->get();

这样,它将返回一个与名称相等的对象数组,而不是类似的匹配项。可以用这种方式进行%LIKE%搜索吗?

您应该这样链接它们:

DB::table('your-table-name')
    ->where('category','=','$c->id')
    ->where('name','=','$c->name')
    ->where('email', 'LIKE', '%test%')
    ->get();

不知怎的我在文档中读到它不应该是这样的,但它是这样的,谢谢