My first guess is because the necessary fields required by the contains statement to do the join are not included when specifying the contains clause for Disciplina and DisciplinasEvento.
-- i.e. the query cant get DisciplinasEvento if Disciplina.id is not retrieved. The query can't get Modalidad if DisciplinasEvento.modalidad_id is not retrieved.
Take a look at the SQL generated via DebugKit or sql_dump to see what fields have been retrieved.
On Tuesday, 15 October 2013 08:21:31 UTC+10, Fabian Olmos wrote:
On Tuesday, 15 October 2013 08:21:31 UTC+10, Fabian Olmos wrote:
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 modelsclass 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:
Post a Comment