2
有沒有方法可以檢查CakePHP的模型關係?在CakePHP中檢查模型關係
一個模型在桌子上保存兩次,我真的懷疑我的關係有問題。問題是我有很多桌子,所以這真的很痛苦。我想知道是否有一個更確定和簡單的方法做到這一點可能會自動?提前致謝!
有沒有方法可以檢查CakePHP的模型關係?在CakePHP中檢查模型關係
一個模型在桌子上保存兩次,我真的懷疑我的關係有問題。問題是我有很多桌子,所以這真的很痛苦。我想知道是否有一個更確定和簡單的方法做到這一點可能會自動?提前致謝!
您可以使用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);
}
}