Cakephp 查找hasMany关系的数组

Cakephp 查找hasMany关系的数组,cakephp,cakephp-1.3,Cakephp,Cakephp 1.3,我有这样的关系: 项目具有多个属性 房产有多种价格 在项目页面上,我想显示: 项目、其性质和最新费率 到目前为止,我有: $this->set('rates', $this->Rate->find('all', array( 'conditions' => array('Property.project_id' => $id), 'fields' => array('Rate.id', 'Rate.rate', 'Rate.floor_

我有这样的关系:

  • 项目具有多个属性
  • 房产有多种价格
在项目页面上,我想显示:

  • 项目、其性质和最新费率
到目前为止,我有:

$this->set('rates', $this->Rate->find('all', array(
    'conditions' => array('Property.project_id' => $id),
    'fields' => array('Rate.id', 'Rate.rate', 'Rate.floor_rise', 'Property.id'),
    'order' => array('Rate.created DESC')
)));
这给出了各个物业的所有价格,但我只想要最新的价格


我该怎么做这个查询呢?

'all'
更改为
'first'
,因为你已经有了一个好的
'order'
你应该很好。

'all'
更改为
'first'
,因为你已经有了一个好的
'order'
你应该很好

$this->set('rates', $this->Rate->find('first', array(
'conditions' => array('Property.project_id' => $id),
'fields' => array('Rate.id', 'Rate.rate', 'Rate.floor_rise', 'Property.id'),
'order' => array('Rate.created DESC')
))))


))))

如果您希望结果显示在一个整洁的数组中,那么设置“containable”可能是值得的;如果您希望结果显示在一个整洁的数组中,那么设置“containable”可能是值得的;如果您希望结果显示在一个整洁的数组中,那么设置“containable”可能是值得的;如果您希望结果显示在一个整洁的数组中,那么设置“containable”可能是值得的;如果您希望结果显示在一个整洁的数组中,那么设置“containable”可能是值得的。然而@ianmjones的响应更像是“蛋糕式”的,或者在现有代码中添加
'limit'=>1
。然而@ianmjones的反应更像是“蛋糕式”