赞!我的模型没有被配置为可包含的。以下查询不显示正确的结果(我想检索所有类别中两个日期之间的所有可用汽车)
$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' => ''
)
);
}