avenirer / CodeIgniter-MY_Model

Base model (MY_Model) for the Codeigniter framework.
325 stars 204 forks source link

Ability to pass in additional params (not a column) to model methods? #264

Open louiswalch opened 6 years ago

louiswalch commented 6 years ago

Starting off simple, I would like to do some additional operations when an item's status is being updated. To do this I have added a before_update observer to a method in my model to take care of the logic.

There is a very rare case where I need to do something based on the record's previous status compared to the new one being set. My view has it's previous status, so getting the controller to pass it along to the model isn't a problem. I tried placing it in the array of data to update (hoping it would just get removed prior to hitting the database). Problem is, that array is sanitized before before_update is called.

Can you think of a way to be able to pass in additional information to my model's update method? I'd like to keep it as native as possible.

Thanks for the help!