db-obj mapping. deleting issue. need advice

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

db-obj mapping. deleting issue. need advice

Post by jmut »

Hi,
Lets imaging I have single object refer to single row sittuation. I want to implement delete feature.
So when I hit $obj->delete() I will delete from db...and at this point object should be obsolete... so any further call (in same http request) of $obj->getSomething() or whatever should result in exception.."object deleted or something"...
This is no issue on next request as will not have such record in db so no such object could be created...

So I am thinking I can put a flag...but then again I should call isDeleted() as first call in each method of object. Thats ok unless it's just something really easy to forget and would like to skip. Any pointers to this problem more than welcome.
Post Reply