Devil System Devil System - 5 months ago 24
SQL Question

make a select in querybuilder laravel

how it would be?


$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]

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


Use where method twice:

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