You can override the foreign key by defining it in the association
array.  This is from the manuals Model Chapter about half way down in
the section titled "Defining and Querying with hasMany"

var $hasMany = array('Comment' =>
                         array('className'     => 'Comment',
                               'conditions'    => 'Comment.moderated =
1',
                               'order'         => 'Comment.created
DESC',
                               'limit'         => '5',
                               'foreignKey'    => 'user_id',
                               'dependent'     => true,
                               'exclusive'     => false,
                               'finderQuery'   => ''
                         )
                  );

Geoff
--
http://lemoncake.wordpress.com

On Aug 29, 8:29 pm, "Ananda Putra" <[EMAIL PROTECTED]> wrote:
> I have tables like these:
>
> human_resources
> - id (int primary key autoincrement)
> - employee_id (varchar, as employee registration number like social
> security ID, not autoincrement)
> - name
> - etc
>
> employee_educations
> - id (int primary key autoincrement)
> - employee_id (varchar)
> - education
>
> The association between the tables is:
> human_resources HAS MANY employee_educations
>
> According to cakephp manual, the foreign key in hasMany association
> should be "human_resource_id", but in my case i use "employee_id" as
> reference between both tables. So, how to create hasMany association
> for my case? Should I create "human_resource_id" field in
> employee_educations table as mandatory of cakephp framework??
>
> Thanks in advance.
>
> --
> Regards,
> Ananda Putra


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

Reply via email to