Ads 4 You

Yii2 model relation with multiple conditions

Email Id : phpmk888@gmail.com

Yii2 model relation with multiple conditions

In AR Model Relations you can add multiple ON condition using andOnCondition method.


 public function getInvoiceItem(){   
           return $this->hasOne(Invoice::className(), ['order_no' => 'order_no'])->andOnCondition(['item' => $this->order_item])->andOnCondition(['user_id' => $this->user_id]);   
      }  


Yii2 model relation with multiple conditions

Comments

  1. this relation could not use in with() function in ActiveQuery.

    ReplyDelete

  2. I like your suggestions they are really helpful. Thank you so much for sharing this post.
    Yii Framework Team in India

    ReplyDelete

Post a Comment