偉い!私のモデルは包含可能として構成されていません。この次のクエリは正しい結果を表示しません (すべてのカテゴリの 2 つの日付の間に利用可能なすべての車を取得したい)
$car=$this->Genre->find('all', array(
'contain' => array(
'cars'=>array(
'conditions'=>array(
'cars.startdate <=' => $qdu ,
'cars.enddate >=' => $qau
)
)
)
)
);
これは私のジャンルモデルです:
class Genre extends AppModel {
public $actsAs = array('Containable');
public $belongsTo = array(
'houses' => array(
'className' => 'houses',
'foreignKey' => 'houses_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
public $hasMany = array(
'cars' => array(
'className' => 'cars',
'foreignKey' => 'genres_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
}
これは車のモデルです:
class Car extends AppModel {
public $belongsTo = array(
'Genres' => array(
'className' => 'Genres',
'foreignKey' => 'genres_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
public $hasMany = array(
'ways' => array(
'className' => 'ways',
'foreignKey' => 'cars_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
}