bindmodel cakephp code example

Example: bindmodel cakephp

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

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

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

Tags:

Php Example