Tuesday, May 26, 2009

Re: Add "created" field to HABTM join tables

Hi everyone,

Just for letting you know that my 'created' and 'modified" fields are
working with Datetime, Not Null and default set on None.
It is working for every table except join tables as notices by Marcco,
for example :

I have three tables as follow: categories, contacts,
categories_contacts (join tables)

All of them have a 'created' field which are automatically updated
when a new entry is saved. But for the joi tables the SQL query is :

INSERT INTO `categories_contacts` (`category_id`,`contact_id`) VALUES
(12,'96')

As you can see there is no 'created' fields.

I supposed it is like this because for CakePHP developpers maybe join
tables should only have two columns. So is it possible to use the core
behavior and how?
Otherwise, I can still add the datetime in the controller directly.

Thanks for you help!

On 13 mai, 21:25, Lucas Velasco <lucas.vela...@gmail.com> wrote:
> Hi Brendon,
> Same problem even after modifying the datetime field to Allow Null and
> default to Null.
>
> Any ideas?
>
> Thanks.
>
> Lucas
>
> On May 8, 1:57 am, Brendon Kozlowski <Brendon...@hotmail.com> wrote:
>
> > The `created` field must (1)be a datetime field, (2)NULL must be
> > allowed, (3)and default to NULL value.  Once that field is set as
> > such, the magic behavior should begin working.
>
> > On May 7, 7:23 am, "marco.rizze...@gmail.com"
>
> > <marco.rizze...@gmail.com> wrote:
> > > Hi
> > > I have added "created" field to HABTM join tables, but when I try to
> > > do a save I noted that this field aren't updated automatically.
> > > Is it normal or that is some problem?
> > > Many Thanks
--~--~---------~--~----~------------~-------~--~----~
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: