0
좀 관련 테이블이 메인이는 모델입니다 :관계 테이블에 대한 모든 관련 정보를 얻는 방법은 무엇입니까?
<?php
App::uses('AppModel', 'Model');
class Information extends AppModel {
public $useTable = 'informations';
public $displayField = 'name';
public $validate = array(
'name' => array(
'notempty' => array(
'rule' => array('notempty'),
'message' => 'The field name can not be empty',
),
),
'lastname' => array(
'notempty' => array(
'rule' => array('notempty'),
'message' => 'The field lastname can not be empty',
),
),
'email' => array(
'email' => array(
'rule' => array('email'),
'message' => 'The email address is not correct',
),
),
);
public $belongsTo = array(
'Country' => array(
'className' => 'Country',
'foreignKey' => 'countries_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
public $hasMany = array(
'Education' => array(
'className' => 'Education',
'foreignKey' => 'informations_id',
'dependent' => true
),
'Experience' => array(
'className' => 'Experience',
'foreignKey' => 'informations_id',
'dependent' => true
),
'Attachment' => array(
'className' => 'Attachment',
'foreignKey' => 'informations_id',
'dependent' => true
)
);
}
나는 ID와 관련된 모든 데이터를 얻을 필요가 있지만,이 코드를 사용하여 데이터를 얻을 때 :
Array
(
[id] => 9
[name] => Reynier
[lastname] => Perez Mira
[email] => [email protected]
[mobile_phone] => 04241805609
[home_phone] => 02735555899
[address] => asdas
[picture] => skills.png
[other_information] => asdasdasd
[recruitment_status] => Call for Interview
[countries_id] => 9
)
: 교육은 경험과 첨부 파일이 보여되지 않은 테이블에서
public function view($id = null) {
$this->Information->id = $id;
if (!$this->Information->exists()) {
throw new NotFoundException(__('Invalid information'));
}
$this->set('information', $this->Information->read(null, $id));
}
된 정보는이 정보를 얻을 수있다
왜? 나는 무엇인가 놓친다?
$ this-> Information-> recursive = 1;을 설정해보십시오. 읽기 전에 줄에. 당신은 CakePHP 책에서 "Containable"행동을 볼 수도 있고해야 할 수도 있습니다. – Dave