codeigniter-base-model
codeigniter-base-model copied to clipboard
Documentation README.md Callbacks/Observers issue
trafficstars
I think it will be good if you clear this to others.
When we are using callbacks the $row can be object so we better check that so instead of using this,
protected function data_process($row)
{
$row[$this->callback_parameters[0]] = $this->_process($row[$this->callback_parameters[0]]);
return $row;
}
use this
protected function data_process($row)
{
if (is_object($row) && $row->{$this->callback_parameters[0]})//check if object then process
$row->{$this->callback_parameters[0]} = $this->user_model->order_by('level')->get_many($row->{$this->callback_parameters[0]});
elseif (is_array($row) && $row[$this->callback_parameters[0]])//check if array then process
$row[$this->callback_parameters[0]] = $this->user_model->order_by('level')->get_many($row[$this->callback_parameters[0]]);
return $row;
}