Note that there are some explanatory texts on larger screens.

plurals
  1. POCakephp2 Contain Deeper Association
    primarykey
    data
    text
    <p>I need to paginate a table where the I need to see only a project assigned to me, how can I achieve this?</p> <p>What I have is this</p> <pre><code>//My Task Pagination $this-&gt;paginate = array( 'Project' =&gt; array( 'limit' =&gt; $limit, 'contain' =&gt; array('ProjectReminderUser.user_id' =&gt; $this-&gt;Session-&gt;read('Auth.User.id')), 'conditions' =&gt; array( 'User.group_id' =&gt; $this-&gt;Session-&gt;read('Auth.User.group_id'), 'Project.project_status_id' =&gt; PROJECT_STATUS_OPEN, ), ) ); $this-&gt;set('myTasks', $this-&gt;paginate('Project')); //debug($this-&gt;paginate('Project')); </code></pre> <p>but seems like the contain does not work at all. The result of debug looks like this</p> <pre><code>array( (int) 0 =&gt; array( 'Project' =&gt; array( 'id' =&gt; '9', 'project_type_id' =&gt; '0', 'contact_id' =&gt; '2', 'company_id' =&gt; '6', ), 'ProjectReminderUser' =&gt; array( (int) 0 =&gt; array( 'id' =&gt; '11', 'user_id' =&gt; '2', 'project_id' =&gt; '9' ) ), (int) 1 =&gt; array( 'Project' =&gt; array( 'id' =&gt; '1', 'project_type_id' =&gt; '0', 'contact_id' =&gt; '1', 'company_id' =&gt; '3', ), 'ProjectReminderUser' =&gt; array( (int) 0 =&gt; array( 'id' =&gt; '2', 'user_id' =&gt; '1', 'project_id' =&gt; '1' ), (int) 1 =&gt; array( 'id' =&gt; '1', 'user_id' =&gt; '2', 'project_id' =&gt; '1' ) ), ) ) </code></pre> <p>So what I would like to achieve is to have the pagination only show array index 1, because the ProjectReminderUser have user_id = 1 (a project that is assigned to me)</p> <p>something like that. I tried to use containable but it does not work, maybe something wrong with the way I did it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload