継承を実装したかったのですが、この記事に従ってデータベース設計を取得できず、次のようにしかモデルを作成できず、記事のように Model/Behaviour の下にファイル InheritBehavior.php を作成しました。継承をサポートするためにこれらのモデルのデータベースを設計する方法
class Animal extends AppModel{
var $name='Animal';
}
App::import('Model', 'Animal');
class Mammal extends Animal{
public $actsAs = array( 'Inherit' );
} var $name= 'Mammal';
}
App::import('Model', 'Animal');
class Insect extends Animal{
var $name='Insect';
}
Animal: id, age
Mammal: id, no_of_legs ('age' is common)
Insect: id, no_of_wings ('age' is common)
このためのデータベース設計は何ですか(複数テーブルの継承)。
このタイプに関連 (hasOne と belongsTo を使用) の代わりに継承を使用することは良い考えですか? これは Cakephp で十分にサポートされますか?