You have to use two different Keys for the association,

something like:

var $belongsTo = array(
    'Creator' => array(
      'className' => 'User',
      'foreignKey' => 'created_id'
    ),

    'Modifier' => array(
      'className' => 'User',
      'foreignKey' => 'modified_id'
    )
  );


for more complex things, investigate on the
associationForeignKey param (for example i used it for create
a model taht references itself  Article with related Articles)

On Sep 11, 11:09 am, Sen <[EMAIL PROTECTED]> wrote:
> Hi all, i need some help.
>
> I have two table, let's say User and Transaction with this kind of
> relation :
>
> User has some common fields :
>   id
>   username
>   password
>
> Transaction :
>   created_id is a foreign key to model User (id)
>   modified_id is a foreign key to model User (id) too
>
> how do define the model relation with this kind of situation ?
>
> i put it in this way but it does not work.
>
> User model :
>
>   var $hasMany = array(
>     'Transaction' => array(
>       'className' => 'Transaction',
>       'foreignKey' => 'created_id'
>     ),
>
>     'Transaction' => array(
>       'className' => 'Transaction',
>       'foreignKey' => 'modified_id'
>     )
>   );
>
> Transaction model :
>
>   var $belongsTo = array(
>     'User' => array(
>       'className' => 'User',
>       'foreignKey' => 'created_id'
>     ),
>
>     'User' => array(
>       'className' => 'User',
>       'foreignKey' => 'modified_id'
>     )
>   );
>
> Tks.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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