$customers = \dibi::select('*')->from('accounts')->fetchAll();
if($username){
$customers = $customers->where("username", $username);
}
我有这个代码的问题。错误是:
调用数组上的成员函数 where()。
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();