Php 如何在laravel哪里条件下通过数组?

Php 如何在laravel哪里条件下通过数组?,php,mysql,database,frameworks,laravel,Php,Mysql,Database,Frameworks,Laravel,执行上述代码时,显示以下错误 $table='user'; $conditions=array( 'uname' => 'test', 'pwd' => '123'); //uname and pwd are the column names DB::table($table)->where($conditions)->get(); 有人能帮我吗。我不知道您使用的是哪些类,但您的php编译器说您传递的是数组而不是字符串

执行上述代码时,显示以下错误

    $table='user';
    $conditions=array(
      'uname' => 'test', 
      'pwd' => '123'); //uname and pwd are the column names

    DB::table($table)->where($conditions)->get();

有人能帮我吗。

我不知道您使用的是哪些类,但您的php编译器说您传递的是数组而不是字符串,所以可以尝试使用字符串格式传递条件:

ErrorException

strtolower() expects parameter 1 to be string, array given
更新
正如您在docs()中所看到的,您只能将字符串传递给
where
方法,因此您必须这样做:

$conditions = "uname='test'&pwd='123'";

我正在使用laravel的查询生成器。我不知道为什么它不接受where条件中的数组。如果我们使用这样的字符串,我们需要使用“whereraw()”,以这种方式使用它的get result,但我希望通过在其中传递数组元素来输出。我希望我们能找到解决办法。
$select = DB::table($table);
foreach($conditions as $column=>$value){
    $select->where($column,'=',$value);
}
$result = $select->get();