Re: check if a conversation with exactly those users exist

2010-08-17 Thread euromark
yeah!!! a friend helped my out just awesome :) SELECT u.`conversation_id`, c.`title` FROM `faf_conversation_users` u, `faf_conversations` c WHERE c.`id` = u.`conversation_id` GROUP BY u.`conversation_id` HAVING sum(case when u.`user_id` in (\''.implode('\', \'', $users).'\') then 1 else 0 end) =

Re: check if a conversation with exactly those users exist

2010-08-14 Thread schaefer
right now i tried some EXISTS subquery function existingConversations($users, $limit = 5) { $options = array( 'conditions' => array('ConversationUser.user_id'=>$users, 'EXISTS (SELECT * from `faf_conversation_users` AS `ConversationUser2` WHERE Conv

Re: check if a conversation with exactly those users exist

2010-08-14 Thread schaefer
well, maybe somebody has a clue how to do it in sql or in cake (and indirektly in sql then) right now i dont get it to work i shows too many results of course maybe this simply cant be done in a single request..? On 13 Aug., 11:16, AD7six wrote: > On Aug 12, 11:06 pm, schaefer wrote: > > > no

Re: check if a conversation with exactly those users exist

2010-08-13 Thread AD7six
On Aug 12, 11:06 pm, schaefer wrote: > nobody who can help? What working sql are you trying to execute in cake. If you're not sure - your asking the question in the wrong place. hth, AD Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related qu

Re: check if a conversation with exactly those users exist

2010-08-12 Thread schaefer
nobody who can help? On 6 Aug., 22:41, schaefer wrote: > Conversation HM ConversationUser > > I want to check if there is already a conversation with lets say user > 1,2,4 > The problem is that I need 'ConversationUser.user_id'=>$users in the > conditions somehow > but HAVING COUNT(*) = '.count(

check if a conversation with exactly those users exist

2010-08-08 Thread schaefer
Conversation HM ConversationUser I want to check if there is already a conversation with lets say user 1,2,4 The problem is that I need 'ConversationUser.user_id'=>$users in the conditions somehow but HAVING COUNT(*) = '.count($users) ALWAYS returns true then (we already threw the wrong ones out.