Answers for "paginate and sort 2nd level association"


paginate and sort 2nd level association

// link below

// Our case:
MemberNotification -> BelongsTo -> Notification, 
Notification -> HasMany -> NotificationLanguage

$this->MemberNotification->recursive = 0;
$this->set('memberNotifications', $this->paginate());
    'belongsTo' => array(
        'NotificationLanguage' => array(
            'foreignKey' => false,
            'conditions' => array(' = NotificationLanguage.notification_id')

// our purpose just make the NotificationLanguage same level with the Notification, show we can sort 2nd level association

// on the view
<th><?php echo $this->Paginator->sort('NotificationLanguage.title', 'Region'); ?></th>

// we cannot use below code, cannot run: xxxxxx
<th><?php echo $this->Paginator->sort('Notification.NotificationLanguage.title', 'Region'); ?></th>
Posted by: Guest on October-08-2020

Browse Popular Code Answers by Language