RE: explicitly setting timestamps in DataObject

From: Date: Wed, 23 Feb 2005 23:54:49 +0000
Subject: RE: explicitly setting timestamps in DataObject
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17662@lists.php.net to get a copy of this message
> -----Original Message----- > From: Jamie Alessio [mailto:Jamie.Alessio@ucop.edu] > Sent: Wednesday, February 23, 2005 3:46 PM > To: Sasha Sklar > Subject: Re: explicitly setting timestamps in DataObject > > > 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 Jamie, thanks for the tips. Unfortunately, I've already checked both of those, and no dice. It would be nice if it was something that simple. I'm worried that it may be the latter case, which would suck. Although since I am already setting created_on manually, it really doesn't change what I'm writing. But I would like to know if that's the case, since it might come in handy later.

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