metric.php.tmp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * {{name}}。
  4. * {{nameEN}}.
  5. *
  6. * 范围:{{scope}}
  7. * 对象:{{object}}
  8. * 目的:{{purpose}}
  9. * 度量名称:{{name}}
  10. * 单位:{{unit}}
  11. * 时间属性:{{dateType}}
  12. * 描述:{{desc}}
  13. * 定义:{{definition}}
  14. */
  15. class {{code}} extends baseCalc
  16. {
  17. /**
  18. * 度量项计算临时结果。
  19. */
  20. public $result = 1;
  21. // public $result = array();
  22. /**
  23. * 获取自定义数据源pdo句柄。
  24. *
  25. * @access public
  26. * @return PDOStatement
  27. */
  28. public function getStatement()
  29. {
  30. return $this->dao->XXX->query();
  31. }
  32. /**
  33. * 计算度量项。
  34. *
  35. * 对数据源查询得到的数据集进行逐行计算,该函数实现对于一行数据的计算逻辑
  36. * 计算完成后将数据临时记录到$this->result上
  37. *
  38. * @param object $row 数据源的一行数据
  39. * @access public
  40. * @return void|false
  41. */
  42. public function calculate($row)
  43. {
  44. $this->result += 1;
  45. }
  46. /**
  47. * 汇总并获取度量项计算结果。
  48. *
  49. * @param array $options 筛选参数
  50. * @access public
  51. * @return array 度量数据
  52. */
  53. public function getResult($options = array())
  54. {
  55. $records = $this->getRecords(array('value'));
  56. return $this->filterByOptions($records, $options);
  57. }
  58. }