Re: Re: Dates in DataObject
| From: | Justin Patrin | Date: | Fri, 31 Dec 2004 21:23:05 +0000 |
| Subject: | Re: Re: Dates in DataObject | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16543@lists.php.net to get a copy of this message | ||
On Thu, 30 Dec 2004 10:51:04 +0100, Rodrigo Alvarez Fernández
<papipo@gmail.com> wrote:
> Ok, after using DO's Cast and a lot of strange things, it seems that
> this is enough:
>
> function update($do = false)
> {
> unset($this->created);
> parent::update();
> }
This is what I do with my "virtual fields". See the link below (note:
some of this is FormBuilder specific, but much relates to DOs):
http://opensource.21st.de/tiki-index.php?page=Beyond+Advanced
You may also want to do something like:
if (is_object($do)) {
unset($do->created);
}
Just in case you pass in a DO with created set.
>
> On Thu, 30 Dec 2004 10:44:28 +0100, Rodrigo Alvarez Fernández
> <papipo@gmail.com> wrote:
> > Hi PEARs,
> >
> > I have a 'created' datetime field, that onInsert, it gets current date and time:
> >
> > function insert()
> > {
> > require_once 'DB/DataObject/Cast.php';
> > $this->created = DB_DataObject_Cast::sql('NOW()');
> > }
> >
> > I want that onUpdate, leave this as it is. How can I do this?
> >
> > Thanks,
> >
> > Rodrigo.
> >
--
Justin Patrin