我试图得到所有结果的字段总数过滤后,与CakeDC搜索插件。
在我的模型中,我有:
public function getFieldAmountTotal( $fieldNames){
// Can't use recursive -1 because it includes current filtering
// This will only grab the total by id
// Can't not pull id because filtering on related tables
//$totalAmounts = $this->find( 'all', array('fields' => $fieldNames));
$totalAmounts = $this->find( 'all', array('fields' => $fieldNames, 'group' => 'MovieStar.id'));
$grandTotal = array();
foreach($fieldNames as $fieldName){
$grandTotal[$fieldName] = 0;
}
foreach($totalAmounts as $amount){
foreach($fieldNames as $fieldName){
$grandTotal[$fieldName] += $amount['MovieStar'][$fieldName];
}
}
debug('$grandTotal');
debug($grandTotal);
return $grandTotal;
}
当我使用CakePHP过滤器插件时,这非常有效,因为所有的过滤都存储在会话中,并且自动传递。
如何使用当前过滤器插件表单设置在查找中进行过滤?
1条答案
按热度按时间kuhbmx9i1#
我找到了一种方法,将行从控制器传递给模型。
产品型号:
控制器:
结果: