These are the queries related concerning users, conversations, and the
join table.
If it isn't too much trouble, maybe you can point me to a complete
piece of code for the users cotroller, to select a certain user's
conversations. Because i have tried several, and i think this is my
problem.
Thanks for helping,
Oana
SELECT `Conversation`.`id`, `Conversation`.`availability`,
`Conversation`.`created`, `Conversation`.`modified`,
`Conversation`.`description`, `Conversation`.`title`,
`Conversation`.`postscount`, `Conversation`.`ideascount`,
`ConversationsUser`.`conversation_id`, `ConversationsUser`.`user_id`
FROM `conversations` AS `Conversation` JOIN `conversations_users` AS
`ConversationsUser` ON (`ConversationsUser`.`user_id` IN (1) AND
`ConversationsUser`.`conversation_id` = `Conversation`.`id`)
SELECT COUNT(*) AS `count` FROM `conversations_users` AS
`ConversationsUser` LEFT JOIN `conversations` AS `Conversation` ON
(`ConversationsUser`.`conversation_id` = `Conversation`.`id`) LEFT
JOIN `users` AS `User` ON (`ConversationsUser`.`user_id` =
`User`.`id`) WHERE `User`.`id` = 1
SELECT `ConversationsUser`.`conversation_id`,
`ConversationsUser`.`user_id`, `Conversation`.`id`,
`Conversation`.`availability`, `Conversation`.`created`,
`Conversation`.`modified`, `Conversation`.`description`,
`Conversation`.`title`, `Conversation`.`postscount`,
`Conversation`.`ideascount`, `User`.`id`, `User`.`username`,
`User`.`email`, `User`.`password`, `User`.`group`,
`User`.`first_name`, `User`.`last_name` FROM `conversations_users` AS
`ConversationsUser` LEFT JOIN `conversations` AS `Conversation` ON
(`ConversationsUser`.`conversation_id` = `Conversation`.`id`) LEFT
JOIN `users` AS `User` ON (`ConversationsUser`.`user_id` =
`User`.`id`) WHERE `User`.`id` = 1 LIMIT 20
On May 18, 11:53 am, David Christopher Zentgraf <[EMAIL PROTECTED]>
wrote:
> Can you post the SQL queries generated by Cake?
> Sounds really weird.
>
> On 18 May 2008, at 16:04, oana wrote:
>
>
>
> > Hi Keith,
>
> > Your summary is very accurate, that is exactly what's happening.
>
> > This is how i select the conversations for an user, in the user
> > controller:
>
> > $this->set('conversations',$this->paginate('ConversationsUser',
> > array('User.id' => $userId)));
>
> > Thank you for replying.
>
> > On May 18, 6:48 am, Keith <[EMAIL PROTECTED]> wrote:
> >> Hi Oana,
>
> >> Can you post some code?
>
> >> What do you mean by "extract?"
>
> >> It sounds like you've got your HABTM working properly, but when you
> >> try to create a view that shows conversations for a specific user the
> >> join table rows associated with that user are deleted. Is this an
> >> accurate summary of your problem?
>
> >> On May 17, 4:34 am, oana <[EMAIL PROTECTED]> wrote:
>
> >>> I know it has been posted a lor about this topic...but i can't
> >>> figure
> >>> it out. Maybe someone with some experience in cake may help me,
> >>> because i am a newbie.
>
> >>> I have 2 classes, Users and Conversations, between them it's habtm
> >>> relationship, and i have the join table ConversationsUser.
>
> >>> In the Users controller i have a function which extracts all the
> >>> conversations of an user give by it's id. Whenever i try to do this,
> >>> the fields in the join table are deleted.
>
> >>> Can anyone please help me? I didn't post this right away, i tried a
> >>> lot to make it work, but i think it's something big i am missing.
>
> >>> Thanks,
> >>> Oana
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---