That's very odd... with that query you shouldn't get any duplicates.

Are you absolutely sure they're duplicates, not just identical rows in
the database? Do they have the same ID?

Try unbinding the associations - if you get the correct results then
add-in the associations one by one.

Otherwise, try setting the "fields" to "DISTINCT User.id,
User.whatever, ...". Or set the 'group' key to "User.id" - either
should remove the duplicates.

hth
grigri

On Jul 5, 5:51 pm, WhyNotSmile <[email protected]> wrote:
> Thanks grigri, that's a handy tip.
>
> I get the following now (I left out the list of fieldnames, because
> there are loads of them):
>
> SELECT {list of fieldnames}
> FROM `users` AS `User`
> LEFT JOIN `groups` AS `Group` ON (`User`.`group_id` = `Group`.`id`)
> LEFT JOIN `user_types` AS `UserType` ON (`User`.`user_type_id` =
> `UserType`.`id`)
> LEFT JOIN `user_statuses` AS `UserStatus` ON (`User`.`user_status_id`
> = `UserStatus`.`id`)
> LEFT JOIN `user_profiles` AS `UserProfile` ON (`UserProfile`.`user_id`
> = `User`.`id`)
> LEFT JOIN `user_prefs` AS `UserPrefs` ON (`UserPrefs`.`user_id` =
> `User`.`id`)
> LEFT JOIN `user_friends` AS `UserFriend` ON (`UserFriend`.`user_id` =
> `User`.`id`)
> LEFT JOIN `access` AS `Access` ON (`Access`.`user_id` = `User`.`id`)
> WHERE `User`.`group_id` = 1 LIMIT 34
>
> It looks ok (though I'm no expert in mySQL), but when I ran that as
> just a SQL query, i.e. $results = $this->User->query(); I'm still
> getting the duplicated results.
>
> Very confused now :s
>
> On 5 July, 16:27, grigri <[email protected]> wrote:
>
> > I've never tried setting the debug value from the controller; it's
> > possible that it needs to be set up beforehand.
>
> > I do this on some sites like this, in app/config/bootstrap.php:
>
> > if (isset($_GET['setthegorramdebugmode'])) {
> >         Configure::write('debug', $_GET['setthegorramdebugmode']);
>
> > }
>
> > (Obviously, use a different key than 'setthegorramdebugmode' - use
> > whatever you like).
>
> > Then just append '?setthegorramdebugmode=2' on to the end of the URL
> > in the browser, and it will enable debug mode, just for you.
>
> > I don't recommend keeping this in place on live sites, however. It
> > _should_ be safe, but you never know...
>
> > hth
> > grigri
>
> > On Jul 5, 4:12 pm, WhyNotSmile <[email protected]> wrote:
>
> > > Thanks.  I did that in the controller (I don't want to change it for
> > > everything, because it's a live site), but I get:
>
> > > (default) 0 query took ms Nr    Query   Error   Affected        Num. rows 
> > >       Took (ms)
>
> > > at the bottom.  Am I doing something wrong?
>
> > > Thanks,
> > > Sharon
>
> > >     Configure::write('debug', 2);
>
> > > On 5 July, 16:07, grigri <[email protected]> wrote:
>
> > > > Open app/config/core.php, change the line (near the top) to
> > > > `Configure::write('debug', 2);` [from whatever it was].
>
> > > > Now when you access the page, you'll see the SQL log at the bottom.
>
> > > > hth
> > > > grigri
>
> > > > On Jul 5, 3:58 pm, WhyNotSmile <[email protected]> wrote:
>
> > > > > I'm not sure how to get that... I don't have access to the SQL log, as
> > > > > far as I know.  Can you suggest where I might look?
>
> > > > > Thanks.
>
> > > > > On 5 July, 15:35, grigri <[email protected]> wrote:
>
> > > > > > What is the corresponding query in the SQL log?
>
> > > > > > On Jul 5, 3:29 pm, WhyNotSmile <[email protected]> wrote:
>
> > > > > > > I'm doing a paginate query, and it's returning the same row 4 
> > > > > > > times.
> > > > > > > The other results in the set are all present and each is shown 
> > > > > > > once.
>
> > > > > > > Has anyone come across this before?
>
> > > > > > > My Users controller code is as follows:
>
> > > > > > >    $this->paginate = array(
> > > > > > >            'limit' => $limit,
> > > > > > >            'conditions' => $find
> > > > > > >    );
>
> > > > > > >    $userlist = $this->paginate('User');
>
> > > > > > > and at the point of calling this code, $limit is 34 and debug on 
> > > > > > > $find
> > > > > > > gives:
>
> > > > > > > Array
> > > > > > > (
> > > > > > >     [and] => Array
> > > > > > >         (
> > > > > > >             [User.synagogue_id] => 1
> > > > > > >         )
>
> > > > > > > )
>
> > > > > > > Any ideas what I'm doing wrong?  The record is definitely not
> > > > > > > duplicated in the DB.
>
> > > > > > > Thanks!
>
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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