调用数组 php 上的成员函数 where()

Call to a member function where() on array php

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

我对这段代码有疑问。错误是:

Call to a member function where() on array.

fetchAllreturnISelection。您不在 ISelection

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

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

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

$customers = $customersTable->fetchAll();