Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.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 5.2中从数据库检索多条记录_Php_Laravel 5.2 - Fatal编程技术网

Php 在Laravel 5.2中从数据库检索多条记录

Php 在Laravel 5.2中从数据库检索多条记录,php,laravel-5.2,Php,Laravel 5.2,我想检查仅当电子邮件存在且已激活==1时,用户是否登录 在数据库中设置,但激活时始终显示空值 图1: $matchThese = ['email' => $email, 'activated' => '1']; //........ //........ $results = User::where($matchThese)->get(); 图2: $matchThese = ['email' => $email, 'activated' => '1']; //

我想检查仅当电子邮件存在且已激活==1时,用户是否登录

在数据库中设置,但激活时始终显示空值

图1:

$matchThese = ['email' => $email, 'activated' => '1'];
//........
//........
$results = User::where($matchThese)->get();

图2:

$matchThese = ['email' => $email, 'activated' => '1'];
//........
//........
$results = User::where($matchThese)->get();
试试这个

$user = DB::table('users')->where([
   ['email', '=', $email],
    ['activated', '=', '1'],
])->get();
或 使用数组生成where子句以检查多个条件。
您可以使用模型类使用where子句获取数据。


另一个例子(雄辩):

$matchThese = ['email' => $email, 'activated' => '1'];
//........
//........
$results = User::where($matchThese)->get();

在where子句中放入
where(数组(“email”=>$email,“activated”=>1))
并查看它是否解决请将代码作为文本而不是代码的屏幕截图放在问题中谢谢它像charm@UNknow将此问题标记为已解决,或将此答案标记为正确