Friday, February 27, 2009

Re: hasAndBelongsToMany (HABTM) and Pagination

Not work...

Warning (512): SQL Error: 1054: Unknown column 'Site.category_id' in
'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line
514]
Query: SELECT COUNT(*) AS `count` FROM `tags` AS `Tag` WHERE
((`Site`.`category_id` = 2) AND (`Tag`.`id` = 2))
Warning (512): SQL Error: 1054: Unknown column 'Site.title' in 'field
list' [CORE/cake/libs/model/datasources/dbo_source.php, line 514]
Query: SELECT `Site`.`title`, `Site`.`description`, `Site`.`vote`,
`Tag`.`tag` FROM `tags` AS `Tag` WHERE ((`Site`.`category_id` = 2)
AND (`Tag`.`id` = 2)) LIMIT 20

Other idea? :)

Gianluca

On Feb 26, 6:21 pm, mscdex <msc...@gmail.com> wrote:
> On Feb 26, 10:46 am, Gianluca Gentile <gianluca.gent...@gmail.com>
> wrote:
>
> > I want to use pagination with this conditions (for example):
>
> > Site.category_id = '1' AND Tag.id = '1' OR Tag.id = '2'
>
> Try:
> var $paginate = array('conditions' => array('AND' => array
> ('Site.category_id' => 1, 'OR' => array('Tag.id' => 1, 'Tag.id' =>
> 2))), 'recursive' => 0);
>
> You may want to specify what fields you want in there as well by
> specifying an additional sub-array called 'fields'. For example:
> var $paginate = array('fields' => array('Site.title',
> 'Site.description', 'Site.vote', 'Tag.tag'), 'conditions' => array
> ('AND' => array('Site.category_id' => 1, 'OR' => array('Tag.id' => 1,
> 'Tag.id' => 2))), 'recursive' => 0);

--~--~---------~--~----~------------~-------~--~----~
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: