はい、BigAnimalというモデルを作成し、$ useTable = 'animals'を定義することができます。 beforeFindとbeforeSaveを定義して、毎回型を 'ビッグ'に設定します。 SmallAnimalモデルでも同じことができます。これは、あなたがこれを達成することができます方法ですがここでは一例
class BigAnimal extends AppModel {
var $useTable = 'animals';
function beforeFind($queryData) {
// set type to big here
}
function beforeSave() {
// set type to big here
}
}
あり、表に1対1のモデルを維持する方が良いだろうと思われます。次に、同じモデルから大小の動物を照会するために必要な機能を追加することができます。コードを少しきれいに保ちます。そうですね、
class Animal extends AppModel {
function findBigAnimals() {
return $this->find('all', array('conditions' => array('type' => 'big')));
}
function findSmallAnimals() {
return $this->find('all', array('conditions' => array('type' => 'small')));
}
}