You should name both of your associations with different names. For
example:
Transaction model :
var $belongsTo = array(
'User_created' => array(
'className' => 'User',
'foreignKey' => 'created_id'
),
'User_modified' => array(
'className' => 'User',
'foreignKey' => 'modified_id'
)
);
User model :
var $hasMany = array(
'Transaction_created' => array(
'className' => 'Transaction',
'foreignKey' => 'created_id'
),
'Transaction_modified' => array(
'className' => 'Transaction',
'foreignKey' => 'modified_id'
)
);
Hope this helps.
On Sep 11, 4: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
-~----------~----~----~----~------~----~------~--~---