简体   繁体   English

Laravel 5.1查询生成器

[英]Laravel 5.1 Query Builder where AND where

Hello could you help me with laravel 5.1 query builder. 您好,您可以使用laravel 5.1查询生成器来帮助我。

I want to create a query that has where AND where. 我想创建一个查询,其中有何处何处。

I have already read the whole documentation but i could get any answer. 我已经阅读了整个文档,但可以得到任何答案。

This is my query: 这是我的查询:

 DB::table('connected_users')
        ->where('user_id',$user->id)
        ->where('connected_id',$id)
        ->update(['status' => '2']);

This is my route Code: 这是我的路线代码:

Route::post('teacher/{id}/connection/approve','ConnectController@aproveConnection');

This is my Laravel Controller Code: 这是我的Laravel控制器代码:

public function aproveConnection($id){

   $user = Auth::user();

   DB::table('connected_users')

      ->where('user_id',$user->id)
      ->where('connected_id',$id)
      ->update(['status' => '2']);

       return Redirect::back();
}

This is my POST form: 这是我的POST表格:

<form method="POST" action="../teacher/{{ $pend_user->id }}/connection/approve">
   {!! csrf_field() !!}
   <input type="submit" value="Αποδοχή Φίλου">
</form>

Using multiple where() 's is the equivilent of an AND operator. 使用多个where()是AND运算符的等效项。 Query will only pass if both where() clauses meet your search criteria. 仅当两个where()子句均符合您的搜索条件时,查询才会通过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM