Yii 1.1: insert-delayed-behavior

Allows to save model with INSERT DELAYED query
2 followers

This behavior allows to save model with INSERT DELAYED.

Requirements

Yii 1.1 or above

Usage

Define behaviors() method in your ActiveRecord mode as follows:

Model.php

public function behaviors()
{
    return array(
        'saveDelayed' => array(
            'class' => 'ext.behaviors.insert-delayed.InsertDelayedBehavior'
            'afterSaveFunction' => 'afterSave',
            'beforeSaveFunction' => 'beforeSave', 
            'onFailSimpleInsert' => true,
        );
    );
}

and now you can call saveDelayed() instead of save() inside controller:

Controller.php

public function saveModel($model)
{
    ...
    $model->saveDelayed();
    ...
}

By default afterSave function call is disabled. If you specify a function to call after save, you can't get there primary key of inserted model.

Note that INSERT DELAYED is possible only when model just created.

Resources

Insert delayed behavior on GitHub

Total 2 comments

#11019 report it
Anatoly Rugalev at 2012/12/10 12:12pm
Version 0.2

Version 0.2 is released

You can post your issues to issues page on GitHub

#11001 report it
Anatoly Rugalev at 2012/12/10 04:22am
Bug

There is a bug.

You should delete a line 65 or update behavior from GitHub repository. Will fix download archives as soon as possible

Leave a comment

Please to leave your comment.

Create extension