dev-master
9999999-devSupport simple ActiveRecord relations
MIT
The Requires
by Vitaly Zaslavsky
yii2 activerecord relations
Support simple ActiveRecord relations
Π Π°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅, ΠΊΠΎΡΠΎΡΠΎΠ΅ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π»Π΅Π³ΠΊΠΎ ΡΠΎΠ·Π΄Π°Π²Π°ΡΡ ΡΠ²ΡΠ·ΠΈ ΠΌΠ΅ΠΆΠ΄Ρ ΡΠ°Π·Π»ΠΈΡΠ½ΡΠΌΠΈ ActiveRecord ΠΌΠΎΠ΄Π΅Π»ΡΠΌΠΈ., (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist vtvz/yii2-relations
or add, (*4)
"vtvz/yii2-relations": "*"
to the require section of your composer.json., (*5)
ΠΠ»Π°ΡΡ vtvz\relations\Relations ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ΠΌ., (*6)
ΠΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ Π²ΡΠ΅ Π²ΠΈΠ΄Ρ ΡΠ²ΡΠ·Π΅ΠΉ ΠΈ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΡΠ΄ΠΎΠ±Π½ΠΎ ΠΈΡ Π½Π°ΡΡΡΠ°ΠΈΠ²Π°ΡΡ., (*7)
ΠΡΠΈΠΌΠ΅Ρ:, (*8)
[ 'class' => Relations::className(), 'relations' => [ /* many to many relation type */ 'items' => [ 'model' => Item::className(), 'link' => ['id' => 'itemId'], 'viaTable' => 'order_has_item', 'viaLink' => ['orderId' => 'id'], 'inverseOf' => 'orders', ], /* one (customer) to many (orders) relation type */ 'customer' => [ 'model' => Customer::className(), 'link' => ['id' => 'customerId'], 'type' => 'one', ], /* one to one relation type with delete */ 'orderInfo' => [ 'model' => OrderInfo::className(), 'link' => ['id' => 'id'], 'type' => 'one', 'delete' => true, ], /* many (somethings) to one (order) relation type. All somethings deletes with its order */ 'somethings' => [ 'model' => Something::className(), 'link' => ['orderId' => 'id'], 'type' => 'many', ] ], ], ]; } } ?>
Π Π°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡ Π½Π° ΡΡΠ°Π΄ΠΈΠΈ ΡΠ°Π½Π½Π΅ΠΉ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ. ΠΡΠΆΠ½Π° ΠΏΠΎΠΌΠΎΡΡ Π² ΠΏΠΎΠΊΡΡΡΠΈΠΈ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΡ ΡΠ΅ΡΡΠ°ΠΌΠΈ ΠΈ ΡΠΎΠ·Π΄Π°Π½ΠΈΠΈ Π½ΠΎΡΠΌΠ°Π»ΡΠ½ΠΎΠΉ Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΠΈ., (*9)
Support simple ActiveRecord relations
MIT
yii2 activerecord relations