codeigniter-base-model icon indicating copy to clipboard operation
codeigniter-base-model copied to clipboard

set callback option from controller

Open umefarooq opened this issue 13 years ago • 1 comments
trafficstars

there should be option to set callbacks from controller all before, after variables are protected we can not set them from controller there should be set_callback function to set before or after callbacks with type

$this->child_model->set_callback('before_get','test1'); 

so we will not duplicate model right now if you set any callback for example before_get will be called for all getting records

class child_model extend MY_Model
{

protected $before_get = array('test');

}

or for sprecific get we have to do this

class child_model extend MY_Model
{

function get_all()
{
  $this->before_get = array('test');

 return parent::get_all();
}

function get()
{
  $this->before_get = array('test1');

 return parent::get();
}

}

i did some setting callbacks from controller

http://scrp.at/bz7

looking some more better option

umefarooq avatar Jul 16 '12 11:07 umefarooq

Inside of your controller, why not use $this->child_model->trigger('before_get') ?

inda5th avatar Sep 13 '12 21:09 inda5th