Beispiel #1
0
 public function testDetectsNonSyntaxException()
 {
     $code = 2002;
     $message = "SQLSTATE[HY000] [2002] Connection reset by peer";
     $pdoException = new \PDOException($message, $code);
     $this->assertFalse(InvalidQueryException::isInvalidSyntax($pdoException));
 }
Beispiel #2
0
 /**
  * @param string $sql
  * @param array $bind
  * @param bool $hasCaughtException
  * @return \PDOStatement
  */
 protected function doQuery($sql, array $bind, $hasCaughtException = false)
 {
     try {
         $stmt = $this->getConnection()->prepare($sql);
         $stmt->execute($bind);
         return $stmt;
     } catch (\PDOException $exception) {
         if (InvalidQueryException::isInvalidSyntax($exception)) {
             throw new InvalidQueryException($sql, $bind, $exception);
         } elseif (RuntimeException::hasServerGoneAway($exception) && !$hasCaughtException) {
             $this->reconnect();
             return $this->doQuery($sql, $bind, true);
         }
         throw RuntimeException::createFromException($exception);
     }
 }