Wednesday, April 29, 2009

Re: "created" not filling right

hi daniel,

> $this->MyModel->findById($id);
> $this->MyModel->create();
> $this->MyModel->save($this->data);
>
> the "created" column is filled with NULL!
>
> Is it wrong to do those operations like that? (I realy dont think so)

You're passing a created/modified value when saving, so cake will use
them - there are times when you need to enter a created/modified date
that is not now!

// find record
$this->data = $this->MyModel->findById($id);
// resent data
$this->data['MyModel']['id'] = null;
$this->data['MyModel']['created'] = null;
$this->data['MyModel']['modified'] = null;
// pass data to model, calls validation, resets behaviours etc
$this->MyModel->create($this->data);
$this->MyModel->save();

hth

Jon

--

jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: