我定義的方法在ATK4與表達領域是:
$this->addExpression('answered')->set(function($model,$select){
return $select->dsql()
->table('answer')
->field($select->expr('if(count(*)>0,"Y","") as answered'))
->where('usecollection_id',$select->getField('id'))
->where('student_id',$this->api->auth->get('id'));
})->type('boolean')->caption('Besvaret');
它的工作原理我的開發機上很好,但在生產服務器它拋出一個致命錯誤:PHP的致命錯誤:使用$這個時候不要在file.php
這是問題的行對象上下文:
$this->api->auth->get('id')
任何想法是什麼原因造成這種差異,以及如何使它工作?
只需將$ this更改爲$ select即可。很簡單。謝謝。 – jeppeb
啊,看,告訴你有更好的方法:)謝謝DarkSide! –