-1

I have the following code which works:

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

How would I specify the AND parameter so that I can query on multiple conditions?

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

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

Doesn't work.

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

To clarify, I'm looking specifically for a query builder solution, not an Eloquent solution.

Chris Forrence
  • 10,042
  • 11
  • 48
  • 64
indian
  • 75
  • 1
  • 1
  • 5

1 Answers1

0

Use where method twice:

$users = DB::table('account')
->where('login', '=', $login)
->where('password', '=', $password)
->get();
jaysingkar
  • 4,315
  • 1
  • 18
  • 26