public function execute(IWebRequest $request, IWebResponse $response)
 {
     DebugLog::separator();
     DebugLog::log($request->postAll());
     $feeding = $this->feedingRepository->getInProgressOrNew();
     $this->executeInner($request, $response, $feeding);
     if ($request->post('docommit', false)) {
         $feeding->setStatus(Feeding::STATUS_Finalized);
         $this->model->setStatus($feeding->getStatus());
     }
     $this->feedingRepository->save($feeding);
     return $this->model;
 }
Esempio n. 2
0
 protected static function finishQueryLog(&$queryLog, $result = false)
 {
     if ($queryLog == false) {
         return false;
     }
     // save finish time and number of affected rows
     $queryLog['time_finish'] = sprintf('%f', microtime(true));
     $queryLog['time_duration_ms'] = ($queryLog['time_finish'] - $queryLog['time_start']) * 1000;
     $queryLog['affected_rows'] = self::getMysqli()->affected_rows;
     // save result information
     if ($result) {
         $queryLog['result_fields'] = $result->field_count;
         $queryLog['result_rows'] = $result->num_rows;
     }
     // build backtrace string
     $queryLog['method'] = '';
     $backtrace = debug_backtrace();
     while ($backtick = array_shift($backtrace)) {
         // skip the log routine itself
         if ($backtick['function'] == __FUNCTION__) {
             continue;
         }
         if ($backtick['class'] != __CLASS__) {
             break;
         }
         // append function
         if ($queryLog['method'] != '') {
             $queryLog['method'] .= '/';
         }
         $queryLog['method'] .= $backtick['function'];
     }
     // append to static log
     if (MICS::isFeatureLoaded('DebugLog')) {
         DebugLog::log($queryLog);
     }
 }
 protected function insert(Feeding $feeding)
 {
     DebugLog::log('1');
     $feeding->setId($this->uuidHelper->get());
     DebugLog::log('2');
     DebugLog::log('3');
     $this->dbFactory->getConnection()->update("insert into feedings set\n\t\t\t\t  `id`=:id\n\t\t\t\t, `date_time`=:date_time\n\t\t\t\t, `status`=:status\n\t\t\t\t, `breast_left`=:breast_left\n\t\t\t\t, `breast_right`=:breast_right\n\t\t\t\t, `milking`=:milking\n\t\t\t\t, `pee`=:pee\n\t\t\t\t, `poo`=:poo\n\t\t\t\t, `bottle`=:bottle\n\t\t\t", array('id' => $feeding->getId(), 'date_time' => $feeding->getDateTime()->format('Y-m-d H:i:s'), 'status' => $feeding->getStatus(), 'breast_left' => $feeding->getBreastLeft(), 'breast_right' => $feeding->getBreastRight(), 'milking' => $feeding->getMilking(), 'pee' => $feeding->getPee(), 'poo' => $feeding->getPoo(), 'bottle' => $feeding->hasBottle() ? $feeding->getBottle()->encode() : null));
     DebugLog::log('4');
 }