Example #1
0
 public function execute()
 {
     $query = $this->build();
     $start = microtime(1);
     $this->executed = true;
     if (!($this->result = $this->driver->query($query))) {
         $error = $this->driver->queryErrorMessage($this->result);
         if (null !== $this->logResourceId) {
             /**
              * @var Log $log
              */
             $log = DependencyRepository::get($this->logResourceId);
             $log->push('(-1) ' . $query . "\n: " . $error . ' ' . $query, Log::TYPE_ERROR);
         }
         $exception = new Database\Exception($error, Database\Exception::QUERY_ERROR);
         $exception->query = $query;
         throw $exception;
     }
     if (null !== $this->logResourceId && DependencyRepository::get($this->logResourceId) !== null) {
         /**
          * @var Log $log
          */
         $log = DependencyRepository::get($this->logResourceId);
         $log->push(round(microtime(1) - $start, 4) . ' s. (' . $this->rowsAffected() . ') ' . $query);
     }
     return $this;
 }