-3
        $customers = \dibi::select('*')->from('accounts')->fetchAll();
    if($username){
        $customers = $customers->where("username", $username);
    }

I have got problem with this code. Error is:

Call to a member function where() on array.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
snoopdog
  • 3
  • 1

1 Answers1

1

fetchAll return ISelection. You dont call Where on ISelection

if($username){
  $customers = \dibi::select('*')->from('accounts')->where("username", $username)->fetchAll();
}

or

$customersTable = \dibi::select('*')->from('accounts');

if($username){
  $customersTable = \dibi::select('*')->from('accounts')->where("username", $username);
}

$customers = $customersTable->fetchAll();
phoniq
  • 228
  • 1
  • 5