Re: explicitly setting timestamps in DataObject

From: Date: Wed, 23 Feb 2005 23:46:17 +0000
Subject: Re: explicitly setting timestamps in DataObject
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17660@lists.php.net to get a copy of this message
Hey, I had good success with this board last time, so I thought I'd try again. This time I spent a lot more time reading through documentation and code before posting. I have a table with 2 timestamp fields, modified_on and created_on. Following the documentation for the version of mysql I'm using, modified_on should be updated every time the row is updated, and created_on should be left alone unless explicitly set. My idea was to set created_on explicity in the overloaded insert() method for the DataObject class. So I put the statement: $this->created_on = date('Ymdhis'); in the insert statement before called parent::insert(). And it totally didn't work. At first I thought I had screwed up the format of the timestamp. But when I set debug to 5, I saw this: INSERT INTO comment (comment_comment_type , comment_comment_status , comment_user_id , comment_item_id , comment_title , comment_body ) VALUES ( 3 , 1 , 2548 , 21 , 'analogically umm twitched kneeled walking after iguana' , 'Hello, that pill bug is much more archaic than some flirtatious woodchuck. Jeez, the effective krill ' ) The insert statement is not including created_by. But when I output the member var before and after the insert, it shows as being there. Any clues? Sasha,
Look at the class definition for your DataObject. Is there a line this? var $created_on; And in your theDataBaseName.ini file is there also a line for 'created_on' in the correct table section? I've caught myself a few times with the simple mistake of forgetting to re-run createTables.php after modifying the database table structure. It's also quite possible that there is some underlying thing in DataObjects that treates timestamps differently than other types that I don't know about but this is at least a starting point to tracking down your problem. - Jamie

« previous php.pear.general (#17660) next »