Devil System Devil System - 2 months ago 9
SQL Question

make a select in querybuilder laravel

how it would be?

Correct

$name = 'jhon';
$users = DB::table('account')->where('login', '=', $name)->get();


how would be the 'and' parameter?

$login = $request->login;
$password = $request->password;

$users = DB::table('account')->where([
['login', '=', $login],
['password', '=', $password]
])->get();


dont work

$users = DB::table('account')
->where('login', '=', $login and 'password', '=', $password)->get();


PD: please dontmake commets like "why u dont use eloquent?" because is a querybuilder question. THANKS

Answer

Use where method twice:

$users = DB::table('account')
->where('login', '=', $login)
->where('password', '=', $password)
->get();
Comments