Hi Brian,
modified as per your suggestion to:
$this->data = $this->Message->find(
'all',
array(
'joins' => array(
array(
'type' => 'LEFT',
'table' => 'profiles',
'alias' => 'SenderProfile',
'conditions' => array(
'Message.user_id = SenderProfile.user_id'
)
),
array(
'type' => 'LEFT',
'table' => 'profiles',
'alias' => 'RecipientProfile',
'conditions' => array(
'Message.recipient_id = RecipientProfile.user_id'
)
)
)
)
);
Now the resulting SQL joins are fine:
SELECT * FROM `messages` AS `Message`
LEFT JOIN profiles AS `SenderProfile` ON (`Message`.`user_id` =
`SenderProfile`.`user_id`)
LEFT JOIN profiles AS `RecipientProfile` ON (`Message`.`recipient_id`
= `RecipientProfile`.`user_id`)
LEFT JOIN `users` AS `Sender` ON (`Message`.`user_id` = `Sender`.`id`)
LEFT JOIN `users` AS `Recipient` ON (`Message`.`recipient_id` =
`Recipient`.`id`)
WHERE 1 = 1
The problem is that in place of '*' I get all the Message, Sender and
Recipient fields but not the SenderProfile and RecipientProfile ones
(even if I can test with PHPMyAdmin that correct values are returned
with a SELECT * ...).
What do you think? Thank you in advance
Best,
Mario
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---