我想 在ActiceRecord扩展的类的函数中的$link数组中使用OR运算符hasMany。例如,我要获取与用户帐户相关的交易。在SQL中这将是类似的东西,SELECT * FROM transactions WHERE fromAccountId = :id OR toAccountId = :id但是我如何使用Yii2写这个
public function getTransactions() {
return $this->hasMany(Transaction::className(), [
'fromAccountId' => 'id',
'toAccountId' => 'id'
]);
}
Run Code Online (Sandbox Code Playgroud)