Posted By

yigit on 06/17/11


Tagged

db model statistics zend


Versions (?)

zend db model statistics


 / Published in: PHP
 

  1. public function getStats()
  2. {
  3. $result = $this->fetchAll(
  4. $this->select()
  5. ->from(array('r' => 'samsung_sii.record'))
  6. ->columns(array('DAY(RecordDateTime) AS RecordDateTime'))
  7. ->group('DAY(RecordDateTime)')
  8. );
  9.  
  10. // print_r($result); exit();
  11.  
  12. $data = array();
  13.  
  14. foreach ($result as $row) {
  15. $data['xAxis'][] = "'" . $row->RecordDateTime . "'";
  16.  
  17. $result2 = $this->fetchRow(
  18. $this->select()
  19. ->from(array('r' => 'samsung_sii.record'))
  20. ->columns(array('COUNT(RecordID) AS RecordCount'))
  21. ->where('DAY(RecordDateTime) = ?', $row->RecordDateTime)
  22. );
  23.  
  24. $data['yAxis'][] = $result2->RecordCount;
  25. }
  26.  
  27. $data['xAxis'] = implode(', ', $data['xAxis']);
  28. $data['yAxis'] = implode(', ', $data['yAxis']);
  29.  
  30. return $data;
  31. }

Report this snippet  

You need to login to post a comment.