For pagination with relationships I use this:
<CODE>

function ReturnMyArrayForPagination(){
.
.
/* conditional code */
.

    return array(
                                        'MortgageDetail' => array(
                                                'limit'=> 10,
                                                'fields' => array(
                                                                'id',
                                                                
'mortgage_provider_id',
                                                                'name',
                                                                
'mortgage_category_id',
                                                
                                                                '(' . 
$initialrate . ' + 0 ) as initialrate',
                                                                .
                                                                .
                                                                'type_fixed_5y',
                                                                .
                                                                .
                                                                'ads_link',
                                                                
'MortgageProvider.name'
                                                                // 
'UNIX_TIMESTAMP(createddate) as created,
UNIX_TIMESTAMP(updatedate) as updated'
                                              ),
                                                'recursive' => -1,
                                                'joins' => array(
                                                        array(
                                                                'table' => 
'mortgage_categories',
                                                                'alias' => 
'MortgageCategory',
                                                                'type' => 
'LEFT',
                                                                'conditions' => 
array('MortgageDetail.mortgage_category_id =
MortgageCategory.id')
                                                        ),
                                                        array(
                                                                'table' => 
'mortgage_providers',
                                                                'alias' => 
'MortgageProvider',
                                                                'type' => 
'LEFT',
                                                                'conditions' => 
array('MortgageDetail.mortgage_provider_id =
MortgageProvider.id')
                                                        ),
                                                        array(
                                                                'table' => 
'mortgage_providers_general_limits',
                                                                'alias' => 
'MortgageProvidersGeneralLimit',
                                                                'type' => 
'INNER',
                                                                'conditions' =>
array('MortgageProvidersGeneralLimit.mortgage_provider_id =
MortgageProvider.id')
                                                        ),
                                                ),
                                                'conditions' => 
array("{$sWhereCond}"),
                                                'order' => array('initialrate')
                                        )
                                );
}
</CODE>

Maybe this helps you, I find this very easy and always makes the right thing.
Cheers!

On Fri, Sep 4, 2009 at 11:39 AM, Amit Rawat<[email protected]> wrote:
>
> Can any one tell me how to use pagination with relationship.
>
> for e.g
>
>     $locArray = array(
>                 'hasOne'=>array
>                 ('profile'=>array('className'=>'Profile' ,
>                 'dependent'    =>'true',
>                 'foreignKey' => 'pro_id')));
>
>
>     $this->User->bindModel($locArray);
>
>     $record=$this->paginate('User');
>
> its giving me only User data and not the related model with it. How can i
> get both of them?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to