Exemple #1
0
 /**
  * @param Query $query
  * @return mixed
  */
 protected function executeQuery(Query $query)
 {
     $stmt = $this->connection->prepare($query->getQueryAsText());
     //        var_dump($query, $params);
     if (!$stmt->execute($query->getValues())) {
         //            echo my_backtrace();
         var_dump($stmt->errorInfo(), $query);
         exit;
     }
     $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     if (empty($result)) {
         if (preg_match('/^\\s* INSERT \\s+/six', $query)) {
             $result = $this->connection->lastInsertId();
         }
         if (preg_match('/^\\s* DELETE|UPDATE \\s+/six', $query)) {
             $result = $stmt->rowCount();
         }
     }
     return $result;
 }
Exemple #2
0
 /**
  * @param Query $query
  * @return mixed
  */
 protected function executeQuery(Query $query)
 {
     $stmt = $this->getPreparedStatement($query->getQueryAsText());
     if ($stmt === false) {
         $errorInfo = $this->connection->errorInfo();
         $this->registerNewError($errorInfo[1], $errorInfo[2]);
         return false;
     }
     if (!$stmt->execute($query->getValues())) {
         $errorInfo = $stmt->errorInfo();
         $this->registerNewError($errorInfo[1], $errorInfo[2]);
         return false;
     }
     $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     if ($result === false) {
         $errorInfo = $stmt->errorInfo();
         $this->registerNewError($errorInfo[1], $errorInfo[2]);
         return false;
     }
     $this->rowsCountAffected = $stmt->rowCount();
     return $result;
 }
Exemple #3
0
 /**
  * @param Query $query
  * @param bool $isForceExpandValues
  * @return Query
  */
 public function transformQuery(Query $query, $isForceExpandValues = false)
 {
     $this->isForceExpandValues = $isForceExpandValues;
     $this->values = $query->getValues();
     $this->preparedValues = [];
     $this->numberPlaceholder = 0;
     $this->isHookSkipValue = false;
     $transformQueryAsText = preg_replace_callback($this->getRegexpMain(), [$this, 'transformCallback'], $query->getQueryAsText());
     return Query::create($transformQueryAsText, $this->preparedValues);
 }