How to tell, if a DataObject is already written to DB
Sometimes you want to check, if you're DataObject is still a new object or already written to DB, e..g in your onBeforeWrite() method. You can either check
if($this->ID) { //written to DB, do stuff }
or use DataObject's isInDB()
if($this->isInDB()) { //do something }
which does basically the same but more elegant and makes your code more self descriptive.
Post your comment
Comments
No one has commented on this page yet.
RSS feed for comments on this page | RSS feed for all comments