이 문제는 내 머리를 수십 일간 부딪 히고 있습니다. 내 부서 모델에서 find ('all')를 수행하면 관련 데이터가 반입되지 않습니다. 여기 내 부서 모델입니다 :cakePHP 관련 데이터가 검색되지 않았습니다.
<?php
App::uses('AppModel', 'Model');
class Department extends AppModel {
public $displayField = 'name';
//The Associations below have been created with all possible keys, those that are not needed can be removed
public $belongsTo = array(///check
'District' => array(
'className' => 'District',
'foreignKey' => 'district_id'
)
);
public $hasMany = array(
'Group' => array(
'className' => 'Group',
'foreignKey' => 'department_id' ///check
),
'Request'=>array(
'className' => 'Request',
'foreignKey' => 'department_id',
),
'DepartmentPosition'=>array(
'className'=>'DepartmentPosition',
'foreignKey'=>'department_id',
'dependent'=>true
),
);
}
나는,이 데이터베이스의 모든 부서에서 모든 필드를 반환,하지만이 모든 데이터를 연관 ('모든')에서 찾을 수 있습니까합니다. 부서 컨트롤러에서 : 나는 하나의 관련 부서를 포함, 다른 모델의 어떠한 문제가없는 및 관련 데이터를 반환라서 모델에 문제가있는 것처럼
$departments = $this->Department->find('all');
$this->set(compact('departments'));
느낀다. 예를 들어, 교육구와 관련된 모든 부서를 찾을 수 있습니다.
미리 감사드립니다.
당신은 발견의 모든 매개 변수를 게시 할 수 있습니다(). –
예, 현재 아무 것도 없습니다. 나는이 시점에서 find ('all')를 수행하고 디버그 ($ departments)를 수행하는 뷰에서 수행한다. 고마워 @Danial – Todd