I'm trying to paginate a on a model, Publication, which belongsTo
User. User hasMany Publication, though not all Users have any
Publications. In PublicationsController, I'd like to paginate a list
of Users and each of their Publications.
User:
public $hasMany = array('Publication');
Publication:
public $belongsTo = array('User' => array('type' => 'INNER'), 'MediaType');
publications_controller:
public $paginate = array(
'Publication' -> array(
// ...
),
'User' => array(
'limit' => 20,
'order' => array('User.sort_label' => 'ASC'),
'fields' => array('User.label', 'User.slug'),
'contain' => array(
'Publication' => array(
'fields' => array(
'Publication.title',
'Publication.slug',
'Publication.thumbnail'
),
'MediaType' => array(
'fields' => array('name', 'slug')
)
)
)
)
);
I have a separate 'User' array there because I want to be able to
group the Publications by User, rather than get a list of Publications
with User repeated for each one.
Now, when I paginate against 'User' I get an array like this below.
Array
(
[0] => Array
(
[User] => Array
(
[label] => '...'
[slug] => '...'
[id] => 745
)
[Publication] => Array
(
)
)
[1] => Array
(
[User] => Array
...
This is the right format, but the problem is that it includes an empty
Publication array for those Users without any in the DB. Cake seems to
be ignoring the INNER type. I suspect that it's because I'm trying to
paginate.
I've been searching around and have tried unbinding and rebinding.
However, each thing I've tried results in no change or errors in the
SQL. Is there no way to do this from PublicationsController?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---