本文整理汇总了PHP中MUtil_Model_ModelAbstract::getCol方法的典型用法代码示例。如果您正苦于以下问题:PHP MUtil_Model_ModelAbstract::getCol方法的具体用法?PHP MUtil_Model_ModelAbstract::getCol怎么用?PHP MUtil_Model_ModelAbstract::getCol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MUtil_Model_ModelAbstract
的用法示例。
在下文中一共展示了MUtil_Model_ModelAbstract::getCol方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transformLoad
/**
* The transform function performs the actual transformation of the data and is called after
* the loading of the data in the source model.
*
* @param \MUtil_Model_ModelAbstract $model The parent model
* @param array $data Nested array
* @param boolean $new True when loading a new item
* @param boolean $isPostData With post data, unselected multiOptions values are not set so should be added
* @return array Nested array containing (optionally) transformed data
*/
public function transformLoad(\MUtil_Model_ModelAbstract $model, array $data, $new = false, $isPostData = false)
{
if (!$data) {
return $data;
}
$output = array();
$keyValues = array();
$summarizeCols = $model->getCol('summaryFunction');
$sumReset = array_fill_keys(array_keys($summarizeCols), 0) + array_fill_keys(array_keys(reset($data)), null);
$sumValues = array_fill_keys(array_keys($this->_summarizeOn), $sumReset);
foreach ($data as $row) {
// Add summarize rows to output when the dependent value has changed
foreach ($sumValues as $keyField => $currentValues) {
if (isset($sumValues[$keyField], $row[$keyField]) && array_key_exists($keyField, $keyValues) && $row[$keyField] !== $keyValues[$keyField]) {
$this->_calculateFixedValues($keyField, $keyValues[$keyField], $currentValues);
$output[] = $currentValues;
}
}
// Output the current row itself
$output[] = $row;
// Calculate the new values for the summarised rows
foreach ($sumValues as $keyField => $currentValues) {
if (array_key_exists($keyField, $row)) {
// Create summarize rows
if (!array_key_exists($keyField, $keyValues) || $row[$keyField] != $keyValues[$keyField]) {
$keyValues[$keyField] = $row[$keyField];
$currentValues = $sumReset;
}
}
// Calculate summarize values
foreach ($summarizeCols as $fieldName => $function) {
if (array_key_exists($fieldName, $row) && array_key_exists($fieldName, $currentValues)) {
switch ($function) {
case 'sum':
$currentValues[$fieldName] = $currentValues[$fieldName] + $row[$fieldName];
break;
case 'count':
$currentValues[$fieldName]++;
break;
case 'last':
$currentValues[$fieldName] = $row[$fieldName];
break;
default:
break;
}
}
}
$sumValues[$keyField] = $currentValues;
}
}
foreach ($sumValues as $keyField => $currentValues) {
$keyValue = isset($keyValues[$keyField]) ? $keyValues[$keyField] : null;
$this->_calculateFixedValues($keyField, $keyValue, $currentValues);
$output[] = $currentValues;
}
return $output;
}
示例2: _getFilters
/**
*
* @return array
*/
protected function _getFilters()
{
$filters = array();
foreach ($this->_targetModel->getCol('filter') as $name => $filter) {
$filters[$name] = $filter;
}
return array_merge_recursive($filters, $this->_targetModel->getCol('filters'));
}