Monday, October 14, 2013

Find and HABTM

Hi, now I'm trying to retrieve data using find function like this

$this->Evento->Behaviors->load('Containable');
$this->Evento->recursive = -1;
debug($this->Evento->find('all', array('conditions' => array('Evento.id'=>$this->Convert->decode($evento_id)),
'contain' =>array(
'Caracteristica'=>array('fields'=>array(
                                                                         'activar_foto',
 'activar_grupo',
 'activar_menor',
 'activar_limite',
 'activar_personal'
)
),
'Disciplina'=>array(
'DisciplinasEvento'=>array(
'Modalidad'
)
) ),
           )
)
                                         );
this are my linked models


class Evento extends AppModel {

public $hasOne = array(
       'Caracteristica' => array(
           'className'  => 'Caracteristica',
'foreignKey' => 'evento_id'
        )
    );
   public $hasAndBelongsToMany = array(
        'Disciplina' =>
            array(
                'className' => 'Disciplina',
                'joinTable' => 'disciplinas_eventos',
                'foreignKey'=> 'evento_id',
                'associationForeignKey' => 'disciplina_id',
                'unique' => 'keepExisting',
'with' => 'DisciplinasEvento'
            )
    );
}

class DisciplinasEvento extends AppModel {

public $belongsTo = array(
'Evento' => array(
'className' => 'Evento',
'foreignKey' => 'evento_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Disciplina' => array(
'className' => 'Disciplina',
'foreignKey' => 'disciplina_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Modalidad' => array(
'className' => 'Modalidad',
'foreignKey' => 'modalidad_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
    );
}

class Modalidad extends AppModel {

public $hasMany = array(
'DisciplinasEvento' => array(
'className' => 'DisciplinasEvento',
'foreignKey' => 'modalidad_id'
)
);
}

Question: Why the find function is not retrieving Modalidad data? many thanks

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: