Devil System Devil System - 1 year ago 85
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

Answer Source

Use where method twice:

$users = DB::table('account')
->where('login', '=', $login)
->where('password', '=', $password)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download