I set up a sub-query that needs to utilize 'containable behavior' and I need
to paginate the results.
[code]
$conditionsSubQuery['Friend.user_id'] = $this->Auth->User('id');
$dbo = $this->Friend->getDataSource();
$subQuery = $dbo->buildStatement(
array(
'fields' => array('Friend.friend_id'),
'table' => $dbo->fullTableName($this->Friend),
'alias' => 'Friend',
'limit' => null,
'offset' => null,
'joins' => array(),
'conditions' => $conditionsSubQuery,
'order' => 'Friend.date_added DESC',
'group' => null
),
$this->Friend);
$subQuery = ' User.id IN (' . $subQuery . ') ';
$subQueryExpression = $dbo->expression($subQuery);
$conditions[] = $subQueryExpression;
$this->paginate = compact('conditions'); <------ I'm not sure if this is
correct. If I add contain to the mix I get unexpected results.
$friend = $this->paginate('User');
$this->set(compact('friend'));
[/code]
I got the above query to return the expected results but not sure how to
implement 'contain' and 'paginate'.
I worked through the examples in the book but the sub-query is confusing me
on this one.
I think this is wrong: $this->paginate = compact('conditions'); // I need to
set a limit for paginate and can't do it in the conditions for the
sub-query. This is paginating the sub-query, isn't it?
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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