Hi to everyone
Is it possibile to extend grocery crud model to implement the CRUD log in an external table?
Actually i do that using callback in my controller like this
$crud->callback_after_insert(function ($post_array,$primary_key)
{ $this->userlog->write('ss_EmployeeStatistic',$primary_key,'I'); }
);
$crud->callback_after_update(function ($post_array,$primary_key)
{ $this->userlog->write('ss_EmployeeStatistic',$primary_key,'U'); }
);
$crud->callback_after_delete(function ($primary_key)
{ $this->userlog->write('ss_EmployeeStatistic',$primary_key,'D'); }
);
calling my library UserLog
class Userlog
{
protected $CI;
public function __construct()
{
// Assign the CodeIgniter super-object
$this->CI =& get_instance();
}
function write($tab,$key,$type)
{
$log = array(
'UserID' => 1,
'LogTable' => $tab,
'LogPK' => $key,
'LogType' => $type, // I insert, U update, D delete
'LogDate' => date('Y-m-d H:i:s')
);
$this->CI->db->insert('UserLog',$log);
return true;
}
}
as you see, my library doesn't get "table name" and "type of operation" coming from callbacks automatically, like $primary_key :(
Which are the names of the variable with the table name, typo of operation etc...
Thak you very much