Tuesday, March 31, 2009

Re: HELP, Controller displaying multiple duplicate rows

Could you please provide the whole modified SQL statement?

It looks like you are trying to left join the statuses table twice!
Enjoy,
John

On Apr 1, 6:18 am, Louie Miranda <lmira...@gmail.com> wrote:
> Hello,
>
> I think there is a problem on my parameter on the controller. Because once
> my other tables has multiple entries, the data on the row is duplicated for
> my main controller.
>
> See my code and parameter and the SQL query cakephp produces.http://bin.cakephp.org/saved/44445
>
> The default for cakephp
>
>    1. *$this->set('pdffiles', $this->paginate());*
>    2.
>    3. ON (`Pdffile`.`statuses_id` = `Statuses`.`id`) LEFT
> JOIN<http://www.php.net/join>`users`
>    AS `User`
>    4. --- ON (`Pdffile`.`user_id` = `User`.`id`) LEFT
> JOIN<http://www.php.net/join>`comments`
>    AS `Comment`
>    5. ON (`Comment`.`pdffile_id` = `Pdffile`.`id`) LEFT
> JOIN<http://www.php.net/join>`statuses`
>    AS `Status`
>    6. *ON (`Status`.`pdffile_id` = `Pdffile`.`id`) WHERE 1 = 1 LIMIT 20*
>
> The modified, under controller
>
>    1. $this->Pdffile->recursive = 0;
>    2. *$parsedConditions['Pdffile.user_id'] = $this->Auth->User('id');*
>    3. $this->paginate['Pdffile'] = array <http://www.php.net/array>(
>    'conditions' => $parsedConditions, 'limit' => '50', 'order' =>
> array<http://www.php.net/array>
>    ('Pdffile.timestamp' => 'desc'));
>    4. $this->set('pdffiles', $this->paginate());
>    5.
>    6. ON (`Pdffile`.`statuses_id` = `Statuses`.`id`) LEFT
> JOIN<http://www.php.net/join>`users`
>    AS `User`
>    7. --- ON (`Pdffile`.`user_id` = `User`.`id`) LEFT
> JOIN<http://www.php.net/join>`comments`
>    AS `Comment`
>    8. ON (`Comment`.`pdffile_id` = `Pdffile`.`id`) LEFT
> JOIN<http://www.php.net/join>`statuses`
>    AS `Status`
>    9. ON (`Status`.`pdffile_id` = `Pdffile`.`id`) WHERE `Pdffile`.`user_id`
>    = 17
>    10. ORDER BY `Pdffile`.`timestamp` desc LIMIT 50
>
> Missing where 1 = 1?
>
> How could this be fixed?
> --
> Louie Miranda (lmira...@gmail.com)http://www.louiemiranda.net
>
> Quality Web Hosting -www.axishift.com
> Pinoy Web Hosting, Web Hosting Philippines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: