public function __construct(Connection $connection, $queryString, array $params) { $time = microtime(TRUE); $this->connection = $connection; $this->supplementalDriver = $connection->getSupplementalDriver(); $this->queryString = $queryString; $this->params = $params; try { if (substr($queryString, 0, 2) === '::') { $connection->getPdo()->{substr($queryString, 2)}(); } elseif ($queryString !== NULL) { static $types = ['boolean' => PDO::PARAM_BOOL, 'integer' => PDO::PARAM_INT, 'resource' => PDO::PARAM_LOB, 'NULL' => PDO::PARAM_NULL]; $this->pdoStatement = $connection->getPdo()->prepare($queryString); foreach ($params as $key => $value) { $type = gettype($value); $this->pdoStatement->bindValue(is_int($key) ? $key + 1 : $key, $value, isset($types[$type]) ? $types[$type] : PDO::PARAM_STR); } $this->pdoStatement->setFetchMode(PDO::FETCH_ASSOC); $this->pdoStatement->execute(); } } catch (\PDOException $e) { $e = $this->supplementalDriver->convertException($e); $e->queryString = $queryString; throw $e; } $this->time = microtime(TRUE) - $time; }
/** * @param string sequence object * @return string */ public function getInsertId($name = NULL) { try { return $this->getPdo()->lastInsertId($name); } catch (PDOException $e) { throw $this->driver->convertException($e); } }
public function __construct(Connection $connection, $queryString, array $params) { $time = microtime(TRUE); $this->connection = $connection; $this->supplementalDriver = $connection->getSupplementalDriver(); $this->queryString = $queryString; $this->params = $params; try { if (substr($queryString, 0, 2) === '::') { $connection->getPdo()->{substr($queryString, 2)}(); } elseif ($queryString !== NULL) { $this->pdoStatement = $connection->getPdo()->prepare($queryString); $this->pdoStatement->setFetchMode(PDO::FETCH_ASSOC); $this->pdoStatement->execute($params); } } catch (\PDOException $e) { $e = $this->supplementalDriver->convertException($e); $e->queryString = $queryString; throw $e; } $this->time = microtime(TRUE) - $time; }