2017 © Pedro PelΓ‘ez
 

yii2-extension yii2-extrelations

Support extended ActiveRecord relations

image

vtvz/yii2-extrelations

Support extended ActiveRecord relations

  • Thursday, May 12, 2016
  • by vtvz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Yii2 Relations Extension

Π Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠ΅, ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠ΅ позволяСт Π»Π΅Π³ΠΊΠΎ ΡΠΎΠ·Π΄Π°Π²Π°Ρ‚ΡŒ связи ΠΌΠ΅ΠΆΠ΄Ρƒ Ρ€Π°Π·Π»ΠΈΡ‡Π½Ρ‹ΠΌΠΈ ActiveRecord модСлями., (*1)

Installation

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)

Usage

Класс 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)

The Versions

12/05 2016

dev-master

9999999-dev

Support extended ActiveRecord relations

  Sources   Download

MIT

The Requires

 

by Vitaly Zaslavsky

yii2 activerecord relations