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

我有这个代码的问题。错误是:

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

4

1 回答 1

1

fetchAll返回ISelection。您不会在 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();
于 2018-02-06T07:12:51.513 回答