我得到了这个模型:
class CompanyRestaurantRequest extends AppModel
{
public $name = "CompanyRestaurantRequest";
//public $actsAs = array('Containable');
public $hasMany = array(
"UserRestaurantRequestFeed" => array(
'dependent' => true
)
);
}
class UserRestaurantRequestFeed extends AppModel{
public $name = "UserRestaurantRequestFeed";
public $belongsTo = array("CompanyRestaurantRequest");
public $hasMany = array("UserRestaurantRequestFeedResponse");
}
class UserRestaurantRequestFeedResponse extends AppModel{
public $name = "UserRestaurantRequestFeedResponse";
public $belongsTo = array("UserRestaurantRequestFeed");
}
我正在尝试像这样对 CompanyRestaurantRequest 进行分页:
$this->CompanyRestaurantRequest->recursive = 5;
$this->CompanyRestaurantRequestFeed->recursive = 5;
$this->paginate = array(
'limit' => 10,
'order' => array(
'CompanyRestaurantRequest.id' => 'desc'
)
);
$this->set('requests', $this->paginate("CompanyRestaurantRequest"));
问题是我没有得到 CompanyRestaurantRequestFeedResponse。
我尝试将 ContainableBehavior 附加到 CompanyRestaurantRequest 模型,并在分页设置中使用了包含键,如下所示:
'contain' => array('CompanyRestaurantRequestFeedResponse');
无论我尝试什么,我都无法获得与 CompanyRestaurantRequestFeeds 相关的那些 CompanyRestaurantRequestFeedResponses。
我怎样才能让它工作?
谢谢!