$customers = \dibi::select('*')->from('accounts')->fetchAll();
if($username){
$customers = $customers->where("username", $username);
}
我遇到了这段代码的问题。错误是:
调用成员函数where()on array。
答案 0 :(得分: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();