我正在使用一个自定义的函数,它封装了 findBySql() 来返回行。但是在标题中显示了错误。但是如果我测试使用封装 find() 的自定义函数,它起作用了,为什么?
这是我的行动:
public function actionList()
{
$model = new Loan();
$dataProvider = new ActiveDataProvider(
[
'query' => $model->findValid($_GET['type']),//error comes here
'pagination' => [
'pagesize' => '2',
],
]);
return $this->renderPartial('list', ['model' => $model, 'dataProvider' => $dataProvider]);
}
Run Code Online (Sandbox Code Playgroud)
这是对象贷款的 findxx 函数:
public function findValid($type=null)
{
if($type==null){
return static::findBySql("select * from loan where wmstat&1=1 and (wmstat>>2)&1=0")->all();
}else{
return static::findBySql("select * from loan where wmstat&1=1 and (wmstat>>2)&1=0 and origin="."'".$type."'")->all();
}
}
Run Code Online (Sandbox Code Playgroud)
此外,我可以使用 find() 和 where() 更改位操作并达到相同的效果吗?