insert-delayed-behavior Allows to save model with INSERT DELAYED query

  1. Requirements
  2. Usage
  3. Resources

This behavior allows to save model with INSERT DELAYED.


Yii 1.1 or above


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


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:


public function saveModel($model)

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.


Insert delayed behavior on GitHub