当前位置: 首页>>代码示例>>PHP>>正文


PHP MUtil_Model_ModelAbstract::getCol方法代码示例

本文整理汇总了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;
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:67,代码来源:SumTotalTransformer.php

示例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'));
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:12,代码来源:ModelTranslatorAbstract.php


注:本文中的MUtil_Model_ModelAbstract::getCol方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。