Welcome Guest, Not a member yet? Register   Sign In
Allow Entities to receive save updates
#1

Hi, I like the Entity working with Entities but would really appreciate 2 key improvements:
  • Relax the Model::update return type
    Currently this method return a bool. I need to override this method in such a way that it's capable of returning the updated Entity in case the save method is called with Object as a parameter. Updates in database are often accompanied by changes in calculated columns and I hope to be able to provide this in my project's base Model class by overridingĀ  the update method instead of a providing a separate method.
  • Auto update the Primary Key after insert
    It would help a lot if the Model could by default set the Primary Key of an Entity after an insert. The model know what the primary key is and it knows the last inserted Id - why not allow it to update automatically.
Thanks for considering.
Reply
#2

(This post was last modified: 06-11-2020, 05:24 AM by Jan Zelenka.)

I might have an improvement on the original request. While working on my project, I realized this all can be addressed in a much simpler way.

Please, change the Model::save($data) method's signature to Model::save(&$data)
That way insert and update can remain as they are and users can easily provide the memory updates in derived Model classes.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB