Tea_J;10984731 wrote:
I would definitely suggest the standard way of doing so, w/c is to generally catch all the data from all the fields you have outputted for change option in your form and just run the equivallent update sql for that. general update..
Agreed.
However, if you have a base class to deal with simple ORM (object relational mapping), where all classes inheriting from the base class matches a single table, with a one to one mapping from table row to class instance, and use this class to retrieve and manipulate database data, you can easily implement what you are talking about. You simply keep an instance variable such as an array that stores changed values, and for each setter method, you compare the new value against the old value before store the variable name as a changed variable.
When you call ::store, you check that something has changed before you issue an update to the database.
But if you don't use this way of accessing database data, where you always need to issue a select query before updating the database, you might as well go with the update query no matter if data changed or not, since you would otherwise be issuing an unnecessary select query in most cases (since you'd most likely be following up with an update almost always).