Download the PHP package notamedia/yii2-relation without Composer
On this page you can find all versions of the php package notamedia/yii2-relation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download notamedia/yii2-relation
More information about notamedia/yii2-relation
Files in notamedia/yii2-relation
Download notamedia/yii2-relation
More information about notamedia/yii2-relation
Files in notamedia/yii2-relation
Please rate this library. Is it a good library?
Informations about the package yii2-relation
Saving Related Data in Yii2
Behavior for support relational data management.
- Insert related models from POST array.
- Pre-processing for new models via callback function.
- Delete related models from database which not exist in POST array.
- Skip related models which already exist in database with same attributes.
- Rollback database changes, if relational model save/delete error occurred.
- Support one-to-one and one-to-many relations.
With pre-processing you can set additional logic before create related models. For example, to add additional columns data to the junction table in a many-to-many relationship.
This behavior uses getters for relational attribute in owner model, such getters must return ActiveQuery
object.
If you use string values in ON condition in ActiveQuery
object, then this behavior will throw exception.
Installation
Usages
For make works this behavior you need:
- Add all relational properties to rules as safe attribute.
- Declare getter for relational attribute.
- Put attribute or attribute with callback to relations property of behavior.
- All used models need to have only one primary key column.
One to One Relationships
One to Many Relationships
Many to Many Relationships
With via
:
With viaTable
:
Sorting Data Relationships
All versions of yii2-relation with dependencies
PHP Build Version
Package Version
The package notamedia/yii2-relation contains the following files
Loading the files please wait ....