假设我有一个模型Post和一个Comment相关的模型如下:
Post hasMany Comment
Comment belongsTo Post
如何使用它find('all')来检索每一个Post与其相关联的最新版本Comment?
我尝试将hasOne关系定义Post为:
var $hasOne = array('LatestComment' => array('className' => 'Comment', 'order' => 'LatestComment.created DESC'));
但是,当我执行 a 时Post->find('all'),它每隔Post多次返回一次,每次返回一次Comment,并LatestComment设置为不同的Comments。