add 'recursive' => 2 to your paginate() call
On 13 авг, 23:02, CUA <[EMAIL PROTECTED]> wrote:
> I seek much wisdom. I have been searching and working on this for some
> time and have learned quite a lot aboutpaginationthrough
> experimentation. I am trying to find the best way to do this.
>
> Configure::version() says "1.2.0.7296 RC2"
>
> Project hasMany ProjectsUser
> ProjectsUser belongsTo User and Project
> User hasMany ProjectsUser
>
> I have other fields in the projects_users table I would like to
> access, This is why it is not simply Project hasAndBelongsToMany User.
>
> I would like to retrieve all the projects related to a given user
> usingpaginationand a single view file. This is what I have so far:
> <?php
> //In the ProjectsController
> var $paginate = array(
> 'Project' => array(
> 'order' => array(
> 'Project.id' => 'DESC'
> ),
> 'contain' => array(
> 'Status',
> 'ProjectsUser' => array(
> 'User.username',
> ),
> ),
> 'conditions' => array('Status.name <> "Closed"',
> 'User.username =
> "XXXX"'),
> 'limit' => 15,
> )
> );
> function index() {
> $projects = $this->paginate('Project');
> if(isset($this->params['requested'])) {
> return $projects;
> }
> $this->set(compact('projects'));}
>
> ?>
> /projects/index results in "SQL Error: 1054: Unknown column
> 'User.username'". I can see there is an absence of all the needed
> tables in the JOIN Cake is creating. I am just unsure how to coax
> paginate to generate the necessary query.
>
> I have tried using $this->Project->contain(), however $this->paginate() does
> not respect it. Any advice would be appreciated.
>
> Thank you very much for your time.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---