$this->paginate['Group'] = $parametros; near the end is $this->paginate ['Group'] = $parameters;
On May 28, 8:39 pm, Xoubaman <[email protected]> wrote: > User HABTM Group > Group HABTM User > > When calling pagination I get these queries: > > SELECT COUNT(*) AS `count` FROM `groups` AS `Group` INNER JOIN > `groups_users` AS `GroupsUser` ON (`GroupsUser`.`group_id` = > `Group`.`id` AND `GroupsUser`.`user_id` = 1) WHERE 1 = 1 > > SELECT `Group`.`id`, `Group`.`name`, `Group`.`slug`, > `Group`.`description`, `Group`.`image`, `Group`.`group_comment_count`, > `Group`.`is_public`, `Group`.`created` FROM `groups` AS `Group` WHERE > 1 = 1 ORDER BY `GroupsUser`.`created` DESC LIMIT 5 > > 1054: Unknown column 'GroupsUser.created' in 'order clause' > > So, pagination is doing well the join with GroupsUser to count the > number of records, but fails fetching the groups, although both > queries should use the same paginate parameters. > > ¿I'm missing something? > > The code: > > $this->Group->unbindModel(array('hasAndBelongsToMany'=>array > ('User'))); > $this->Group->bindModel(array('hasOne'=>array('GroupsUser'=>array > ('foreignKey'=>false,'type'=>'INNER','conditions'=>array > ('GroupsUser.group_id = Group.id','GroupsUser.user_id = '. > $user_id))))); > > $parameters = array('contain' => array('GroupsUser'), > 'order' => array('GroupsUser.created' => > 'DESC'), > 'limit' => $this->elementos_por_pagina); > > $this->paginate['Group'] = $parametros; > $groups = $this->paginate('Group'); > $this->set('groups', $groups); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
