[英]CakePHP (1.3) HABTM on the same model saveAll() not working
[英]CakePHP 1.3 HABTM model Pagination
在模型中使用HABTM關系而不是在控制器的paginate變量中使用JOIN一直存在問題,數據很好,但我不能將項目限制設置為20。
我從數據庫中選擇依賴於其功能的項目。
我有一個叫做緊急的功能。
我在緊急列表頁面上。
這應該獲取所有標記為緊急的項目,它可以很好地完成工作,但它會帶回所有結果,而不是我在分頁函數或模型中設置的20個限制。 這是pagien數組代碼
$paginate = array(
'Project' => array(
'limit' => 20,//works fine when paginating just projects
),
'Feature' => array(
'limit' => 1, //did set this to 20 but when looking thought well its going to be the limit of the feature table which will only be 1 anyway, notl imit for the projects
//also tried this below
'Project' => array(
'limit' => 20,//no luck with this
),
),
);
我用它在我的控制器中分頁
$this->paginate('Feature', array(..conditions..)); //this brings all my projects marked urgent but I only want 20!
您是否正在尋找ContainableBehavior ?
$paginate = array(
'Feature' => array(
'contain' => array(
'Project' => array(
'limit' => 20,
....
)
)
)
);
我知道這是一篇過時的文章,並且您正在尋找一種1.3解決方案,但是我將這種技術用於我在1.2 年前編寫的應用程序中,並且絕對有效: 從HABTM關系分頁數據 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.