【发布时间】:2014-10-14 15:59:37
【问题描述】:
我想在 ActiceRecord 扩展的类中的 hasMany 函数中的 $link 数组中使用 OR 运算符。
例如,我想获取与用户帐户相关的交易。在 sql 中它类似于 SELECT * FROM transactions WHERE fromAccountId = :id OR toAccountId = :id 但我如何使用 Yii2 编写它
public function getTransactions() {
return $this->hasMany(Transaction::className(), [
'fromAccountId' => 'id',
'toAccountId' => 'id'
]);
}
【问题讨论】:
标签: php mysql activerecord yii2