调用数组 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.
fetchAll
returnISelection
。您不在 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();
$customers = \dibi::select('*')->from('accounts')->fetchAll();
if($username){
$customers = $customers->where("username", $username);
}
我对这段代码有疑问。错误是:
Call to a member function where() on array.
fetchAll
returnISelection
。您不在 ISelection
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();