여기서 떡 먹고 PHP하세요.CakePHP 2.x 다른 모델에 액세스
Bicycle belongsTo Stand
Stand hasMany Bicycle
Stand belongsTo Station
Station hasMany Stand
나는 CRUD를 구운 다음 자전거를 볼 때 방송국 이름을 표시하려고합니다. 자전거 - 역 관계를 어떻게 정의해야합니까? 또는 스테이션 모델을 자전거 컨트롤러에 포함 시키려면 어떻게해야합니까?
지금까지 시도한 내용. "정의되지 않은 인덱스 : 역 공지 사항 (8)" : BicyclesController.php :
public function index() {
$this->Bicycle->recursive = 2;
$this->set('bicycles', $this->Paginator->paginate());
}
index.ctp :
<?php echo $this->Html->link($bicycle['Station']['name'].$bicycle['Stand']['stand_no'], array('controller' => 'stands', 'action' => 'view', $bicycle['Stand']['id'])); ?>
도움말 어떤이가 발생합니다!