コード例 #1
0
 public function createPDOStatement($dbHandle, $sql, $boundValues, $queryString)
 {
     $pdoStatement = $dbHandle->prepare($sql);
     if (!$pdoStatement) {
         throw PDOExceptionExtractor::getException($dbHandle->errorInfo(), $queryString);
     }
     foreach ($boundValues as $key => $valueBind) {
         $type = ParameterType::getType($valueBind);
         $pdoStatement->bindValue($key + 1, $valueBind, $type);
     }
     try {
         if (!$pdoStatement->execute()) {
             throw PDOExceptionExtractor::getException($pdoStatement->errorInfo(), $queryString);
         }
     } catch (PDOException $exception) {
         $errorInfo = array($exception->getCode(), $exception->getCode(), $exception->getMessage());
         throw PDOExceptionExtractor::getException($errorInfo, $queryString);
     }
     return $pdoStatement;
 }
コード例 #2
0
ファイル: Db.php プロジェクト: letsdrink/ouzo
 public function lastInsertId($sequence)
 {
     $lastInsertId = $this->_dbHandle->lastInsertId($sequence);
     if (!$lastInsertId) {
         throw PDOExceptionExtractor::getException($this->_dbHandle->errorInfo(), "Cannot get sequence value: {$sequence}");
     }
     return $lastInsertId;
 }