2009-10-16 5 views
2

CakePHP의 모델 관계를 확인할 수있는 방법이 있습니까?CakePHP에서 모델 관계 확인하기

하나의 모델이 테이블에 두 번 저장되고 있으며 실제로 내 관계에 문제가 있다고 생각합니다. 문제는 테이블이 너무 많아서 정말 고통 스럽습니다. 이 작업을 자동으로 수행하는 확실하고 쉬운 방법이 있는지 궁금합니다. 미리 감사드립니다!

답변

2

var_dump 또는 print_r을 사용하면 모델이 어떻게 보이는지 확인할 수 있습니다. 모든 모델에 대해 신속하게 수행하려면 AppModel을 수정하여 각 모델이로드 될 때 구조를 덤프하십시오.

class AppModel extends Model { 
    function __construct($id = false, $table = null, $ds = null) { 
     parent::__construct($id, $table, $ds); 

     $this->log("Model [{$this->name}] belongsTo = " . print_r($this->belongsTo, true), LOG_DEBUG); 
     $this->log("Model [{$this->name}] hasOne = " . print_r($this->hasOne, true), LOG_DEBUG); 
     $this->log("Model [{$this->name}] hasMany = " . print_r($this->hasMany, true), LOG_DEBUG); 
     $this->log("Model [{$this->name}] hasAndBelongsToMany = " . print_r($this->hasAndBelongsToMany, true), LOG_DEBUG); 
    } 
}