Hi,
I want to sort a column based on HABTM associations using pagination.
Tables:
1) problems(id, title)
2) users(id, username)
3) problems_users(problem_id, user_id)
Relation ship between problems and users table is HABTM
var $hasAndBelongsToMany = array(
'User' => array
(
'className' => 'User',
`'joinTable' =>
'problems_users',
'foreignKey' => 'problem_id',
'associationForeignKey' => 'user_id'
)
);
I am getting pagination data like below:
Array
(
[0] => Array
(
[Problem] => Array
(
[id] => 5
[title] => 33
)
[User] => Array
(
[0] => Array
(
[id] => 1
[username] => business user
[ProblemsUser] => Array
(
[problem_id] => 5
[user_id] => 1
) )))
I am successfully able to sort on problem title column using <?php
echo $paginator->sort('Title', 'Problem.title'); ?>
but when I am trying to sort on username using <?php echo $paginator->
sort('Username', User.username'); ?> its generating errors
How can I sort a column (username) based on above HABTM associations?
Please help me.
Thanks!!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---