2017-09-14 12 views
1

私は両方の方法を使用している:Laravelの 'join'または 'where'に '='を使用することに違いはありますか?

$this->data = DB::table('projects') 
    ->select('companies_info.*', 'project_roles_types.name AS project_role_name') 
    ->join('project_companies_members', 'project_companies_members.project_id', 'projects.project_id') 
    ->where($some_variable, $project_id) 
    ->get(); 

と:

$this->data = DB::table('projects') 
    ->select('companies_info.*', 'project_roles_types.name AS project_role_name') 
    ->join('project_companies_members', 'project_companies_members.project_id', '=', 'projects.project_id') 
    ->where($some_variable, '=', $project_id) 
    ->get(); 

をし、私のためにそれが=記号を追加または削除のいずれかと同じに取り組んできました。 これが許可されているかどうか誰かが知っていますか?もしそうなら、それを行う最良の方法は何ですか?おかげさまで

答えて

5

// Here we will make some assumptions about the operator. If only 2 values are 
// passed to the method, we will assume that the operator is an equals sign 
// and keep going. Otherwise, we'll require the operator to be passed in. 

だから、あなたが2番目の引数として=を省略した場合、クエリビルダはと一致しており、デフォルトでそこに配置されます、見ることができますあなたが描く行動。

Reference

関連する問題