Details
ActiveRecord Synchronization Behavior
This behavior for automatic or manual sync data between two models, without declaration relation. This behavior must be attached on master model. Main purposes - for sync rarely modified data from more reliable database storage to redis storage for frequently access; Support actual data state in some development cases;
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist insolita/yii2-arsync "*"
or add
"insolita/yii2-arsync": "*"
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply use it in your code by :
See more in code
public function behaviors(){
return [
'ArSyncBehavior'=>[
'class' => ArSyncBehavior::class,
'slaveModel' => \your\model\namespase\Slave::className(),
'slaveScenario'=>'sync',
'errorSaveCallback'=>function($slave){
Yii::error(VarDumper::export($slave->errors));
throw new InvalidConfigException('fail save ');
},
'errorDeleteCallback'=>function($slave){
Yii::error('fail delete '.$slave->getPrimaryKey());
},
'fieldMap' => [
'id'=>'id',
'title' => 'name',
'foo' => 'foo',
'bar' => 'bar',
'baz' => function($master)
{
return $master->baz * 2;
},
],
]
];
}
|
Name: |
yii2-arsync |
Base name: |
yii2-arsync |
Description: |
Add new behaviors to active record actions |
Version: |
- |
PHP version: |
5 |
License: |
MIT/X Consortium License |
All time users: |
14 users |
All time rank: |
10928 |
Week users: |
0 users |
Week rank: |
333  |
|
|
 December 2022
Number 8 |
ActiveRecord is a popular software design pattern many applications and frameworks use to store and retrieve objects in relational tables.
Often applications that use the active record design pattern define hierarchies of class objects and establish relations between enslaver and enslaved person objects.
This package can help applications that use the active record design pattern implementation with the YII framework to automate the process of updating slave objects based on the changes in master objects.
Manuel Lemos |
Not yet rated by the users |
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.
|
Files |
|
File |
Role |
Description |
common (1 file, 2 directories) |
|
Files |
|
File |
Role |
Description |
common (1 file, 2 directories) |