Class design aside, there is a pretty simple way of determining whether to update or create data.
In many of my scenarios, I write a method to update or save class data. The first part of the method creates an UPDATE SQL query and executes it. If rows affected by the execute is 0 then I know that the update criteria was not found indicating that the record does not yet exist. So I then generate an INSERT query and execute that.
This technique saves the step of checking to see that the record exists and then running an UPDATE or INSERT based on that. In many cases you are doing an update so you'll just have the single UPDATE query to execute and all will be fine. However, in some cases you might be performing far more INSERTs than UPDATEs. For these cases you should create methods specifically for inserting data only.
-
Peter