Saving and Deleting Objects

The C, U and D in CRUD is handled by the code generated Save and Delete methods in every object.

Delete should hopefully be self-explanatory. Save will either call a SQL INSERT or a SQL UPDATE, depending on whether the object was created brand new or if it was restored via a Load method of some kind.

Note that you can also call Save passing in true for the optional $blnForceInsert parameter. If you pass in true, then it will force the Save method to call SQL INSERT. Note that dependning on how your table is set up (e.g. if you have certain columns marked as UNIQUE), forcing the INSERT may throw an exception.

Load a Person Object, Modify It, and Save

Before the Save
Person ID: 3
First Name: Ben
Last Name: 5665564

After the Save
Person ID: 3
First Name: FooBar
Last Name: 5665564

Cleaning Up
Person ID: 3
First Name: Ben
Last Name: 5665564