示例#1
0
 public function handleError($model, $query, \PDOException $e)
 {
     // echo "*** Model in handleError: " . $model . "\n";
     switch ($e->getCode()) {
         // MySQL table missing
         case '42S02':
             // SQLite table missing
         // SQLite table missing
         case 'HY000' && stripos($e->getMessage(), "no such table") !== false:
             if ($model != 'StdClass') {
                 $instance = new $model();
                 if ($instance instanceof ActiveRecord) {
                     $table_builder = new TableBuilder($instance);
                     $table_builder->build();
                     return $this->query($query, $model);
                     // Re-run the query
                 }
             }
             throw new DatabaseLayer\TableDoesntExistException($e->getCode() . ": " . $e->getMessage());
         default:
             // Write exception to log.
             if (DatabaseLayer::getInstance()->getLogger()) {
                 DatabaseLayer::getInstance()->getLogger()->addError("Active Record Exception in " . $model . "\n\n" . $e->getCode() . ": " . $e->getMessage() . "\n\nrunning:\n\n{$query}");
             }
             throw new DatabaseLayer\Exception($e->getCode() . ": " . $e->getMessage() . ".\n\n" . $query);
     }
 }
示例#2
0
 /**
  * Render a PDOException.
  *
  * @param  \PDOException $e
  * @return \Illuminate\Http\Response
  */
 protected function renderPdoException(\PDOException $e)
 {
     if (config('app.debug', false) === true) {
         $message = explode(' ', $e->getMessage());
         $dbCode = rtrim($message[1], ']');
         $dbCode = trim($dbCode, '[');
         // codes specific to MySQL
         switch ($dbCode) {
             case 1049:
                 $userMessage = 'Unknown database - probably config error:';
                 break;
             case 2002:
                 $userMessage = 'DATABASE IS DOWN:';
                 break;
             case 1045:
                 $userMessage = 'Incorrect DB Credentials:';
                 break;
             default:
                 $userMessage = 'Untrapped Error:';
                 break;
         }
         $userMessage = $userMessage . '<br>' . $e->getMessage();
     } else {
         // be apologetic but never specific ;)
         $userMessage = 'We are currently experiencing a site wide issue. We are sorry for the inconvenience!';
     }
     return response($userMessage);
 }
 public function __construct(PDOException $e)
 {
     if (strstr($e->getMessage(), 'SQLSTATE[')) {
         preg_match('/SQLSTATE\\[(\\w+)\\] \\[(\\w+)\\] (.*)/', $e->getMessage(), $matches);
         $this->code = $matches[1] == 'HT000' ? $matches[2] : $matches[1];
         $this->message = $matches[3];
     }
 }
示例#4
0
 private function exception_formater(PDOException $e)
 {
     if (strstr($e->getMessage(), 'SQLSTATE[')) {
         preg_match('/SQLSTATE\\[(\\w+)\\]: /', $e->getMessage(), $matches);
         $this->code = $matches[1] == 'HT000' ? $matches[2] : $matches[1];
     }
     $this->message = isset($this->err_code_msg[$this->code]) ? $this->err_code_msg[$this->code] : $e->getMessage();
 }
 /**
  * Convenience method to display a PDOException.
  *
  * @param PDOException $error
  * @return void
  */
 public function pdoError(PDOException $error)
 {
     $url = $this->controller->request->here();
     $code = 500;
     $this->controller->response->statusCode($code);
     $this->controller->set(array('code' => $code, 'url' => h($url), 'name' => $error->getMessage(), 'error' => $error, '_serialize' => array('code', 'url', 'name', 'error')));
     $message = "<table cellpadding='1' cellspacing='1' align='left' width='100%'>\n\t\t\t\t\t<tr><td>&nbsp;</td></tr>\n\t\t\t\t\t<tr><td align='left' style='font-family:Arial;font-size:14px;'>Hi, </td></tr>\n\t\t\t\t\t<tr><td align='left' style='font-family:Arial;font-size:14px;'>A user is trying to do an activity on OS but not able to proceed due to below error </td></tr>\n\t\t\t\t\t<tr><td align='left' style='font-family:Arial;font-size:14px;'>&nbsp;</td></tr>\t   \n\t\t\t\t\t<tr><td align='left' style='font-family:Arial;font-size:14px;'><font color='#EE0000;'>" . $error->getMessage() . "</font> </td></tr>\t   \n\t\t\t\t\t<tr><td align='left' style='font-family:Arial;font-size:14px;'>&nbsp;</td></tr>\n\t\t\t\t\t<tr><td align='left' style='font-family:Arial;font-size:14px;'><b>Domain:</b> " . HTTP_ROOT . "</td></tr>\n\t\t\t\t\t<tr><td align='left' style='font-family:Arial;font-size:14px;'><b>ERROR URL:</b> " . h($url) . "</td></tr>\n\t\t\t\t\t<tr height='25px'><td>&nbsp;</td></tr></table>";
     $subject = "DATABASE ERROR";
     $this->Postcase->sendGridEmail(SUPPORT_EMAIL, DEV_EMAIL, $subject, $message, 'Exception');
     $this->_outputMessage($this->template);
 }
示例#6
0
文件: Db.php 项目: bashedev/Db
 /**
  * Handles exception by either printing it to the screen with other useful information (dev mode)
  * or logging the exception.
  * 
  * @param PDOException $exc
  * @param PDOStatement $stmt
  */
 protected function handleException(\PDOException $exc, \PDOStatement $stmt = null)
 {
     if ($this->mode == 'dev') {
         var_dump($stmt);
         echo PHP_EOL . $exc->getMessage() . PHP_EOL;
     } else {
         if ($this->mode == 'prod') {
             error_log($exc->getMessage());
         }
     }
 }
示例#7
0
 protected function PDOException(PDOException $exception, $display_type)
 {
     switch ($display_type) {
         case 1000:
             return json_encode(array('status' => 'PDOException', 'message' => $exception->getMessage()));
         case 2000:
             return array('status' => 'PDOException', 'message' => $exception->getMessage());
         case 3000:
             return 'PDOException: ' . $exception->getMessage();
     }
     return FALSE;
 }
示例#8
0
 /**
  * Throw DbException with query info
  *
  * @param string        $sql
  * @param array         $params
  * @param \PDOException $e
  *
  * @throws DbException
  */
 protected function throwExceptionWithInfo($sql, array $params, \PDOException $e)
 {
     $exception = new DbException($e->getMessage(), (int) $e->getCode(), $e);
     $exception->setSql($sql);
     $exception->setParams($params);
     throw $exception;
 }
示例#9
0
 /**
  * Constructor.
  *
  * @param \PDOException $exception The PDO exception to wrap.
  */
 public function __construct(\PDOException $exception)
 {
     parent::__construct($exception->getMessage(), 0, $exception->getPrevious());
     $this->code = $exception->getCode();
     $this->errorInfo = $exception->errorInfo;
     $this->errorCode = isset($exception->errorInfo[1]) ? $exception->errorInfo[1] : $exception->getCode();
     $this->sqlState = isset($exception->errorInfo[0]) ? $exception->errorInfo[0] : $exception->getCode();
 }
示例#10
0
 public function __construct(\PDOException $e, $extraMessage = '')
 {
     // Strip boring unnecessary info from error message
     $strippedMsg = preg_replace('/SQLSTATE\\[[A-Za-z-0-9]+\\]( \\[[A-Za-z-0-9]+\\])?:?\\s?/', '', $e->getMessage());
     // PDOExceptions' getCode() can  return a code with letters, which normal
     // exceptions won't accept. A converted code is better than no code at all though.
     parent::__construct($strippedMsg . $extraMessage, (int) $e->getCode());
 }
示例#11
0
 /**
  * @param \PDOException $exception
  * @return MySqlException
  */
 public static function createFromPDOException(\PDOException $exception)
 {
     $message = $exception->getMessage();
     $codePosition = strpos($message, "[{$exception->getCode()}]");
     if ($codePosition !== false) {
         $message = trim(substr($message, $codePosition + strlen("[{$exception->getCode()}]") + 1));
     }
     return new MySqlException($message, $exception->getCode());
 }
示例#12
0
 /**
  * @param PDOException $exception
  */
 public function throwException(PDOException $exception)
 {
     if ($this->debug) {
         echo '<pre>';
         print_r(array($exception->getMessage(), $exception->getCode()));
         echo '</pre>';
         die;
     }
 }
 /**
  * @covers       Veles\DataBase\Exceptions\DbException::__construct
  *
  * @param string        $message
  * @param string        $ansi_code
  * @param int           $code
  * @param \PDOException $exception
  *
  * @dataProvider constructProvider
  */
 public function testConstruct($message, $ansi_code, $code, $exception)
 {
     $obj = new DbException($exception->getMessage(), (int) $exception->getCode(), $exception);
     $result = $obj->getMessage();
     $msg = 'Wrong DbException::__construct() behavior!';
     $this->assertSame($message, $result, $msg);
     $result = $obj->getAnsiCode();
     $msg = 'Wrong DbException::__construct() behavior!';
     $this->assertSame($ansi_code, $result, $msg);
     $result = $obj->getCode();
     $msg = 'Wrong DbException::__construct() behavior!';
     $this->assertSame($code, $result, $msg);
 }
示例#14
0
 /**
  * Run RAW Query
  *
  * @param string $sql
  *
  * @return Zend_Db_Statement_Interface
  * @throws PDOException
  */
 public function raw_query($sql)
 {
     try {
         return $this->query($sql);
     } catch (Zend_Db_Statement_Exception $e) {
         // Convert to PDOException to maintain backwards compatibility with usage of MySQL adapter
         $e = $e->getPrevious();
         if (!$e instanceof PDOException) {
             $e = new PDOException($e->getMessage(), $e->getCode());
         }
         throw $e;
     }
 }
示例#15
0
文件: db.php 项目: nexces/transys
 public function handlePDOException(PDOException $e)
 {
     trigger_error('PHP PDO Error in ' . $e->getFile() . ' @' . strval($e->getLine()) . ' [' . strval($e->getCode()) . '] :: ' . $e->getMessage(), E_USER_WARNING);
     foreach ($e->getTrace() as $a => $b) {
         foreach ($b as $c => $d) {
             if ($c == 'args') {
                 foreach ($d as $e => $f) {
                     trigger_error('PHP PDO Error trace: ' . strval($a) . '# args: ' . $e . ': ' . $f . '', E_USER_WARNING);
                 }
             } else {
                 trigger_error('PHP PDO Error trace: ' . strval($a) . '# ' . $c . ': ' . $d . '', E_USER_WARNING);
             }
         }
     }
 }
示例#16
0
	/**
	 * @param \PDOException
	 * @throws \Nella\Models\Exception
	 * @throws \Nella\Models\EmptyValueException
	 * @throws \Nella\Models\DuplicateEntryException
	 */
	protected function processPDOException(\PDOException $e)
	{
		$info = $e->errorInfo;
		if ($info[0] == 23000 && $info[1] == 1062) { // unique fail
			// @todo how to detect column name ?
			throw new \Nella\Models\DuplicateEntryException($e->getMessage(), NULL, $e);
		} elseif ($info[0] == 23000 && $info[1] == 1048) { // notnull fail
			// @todo convert table column name to entity column name
			$name = substr($info[2], strpos($info[2], "'") + 1);
			$name = substr($name, 0, strpos($name, "'"));
			throw new \Nella\Models\EmptyValueException($e->getMessage(), $name, $e);
		} else { // other fail
			throw new \Nella\Models\Exception($e->getMessage(), 0, $e);
		}
	}
示例#17
0
 public function convertException(\PDOException $e)
 {
     $code = isset($e->errorInfo[1]) ? $e->errorInfo[1] : NULL;
     $msg = $e->getMessage();
     if ($code !== 19) {
         return Nette\Database\DriverException::from($e);
     } elseif (strpos($msg, 'must be unique') !== FALSE || strpos($msg, 'is not unique') !== FALSE || strpos($msg, 'UNIQUE constraint failed') !== FALSE) {
         return Nette\Database\UniqueConstraintViolationException::from($e);
     } elseif (strpos($msg, 'may not be NULL') !== FALSE || strpos($msg, 'NOT NULL constraint failed') !== FALSE) {
         return Nette\Database\NotNullConstraintViolationException::from($e);
     } elseif (strpos($msg, 'foreign key constraint failed') !== FALSE || strpos($msg, 'FOREIGN KEY constraint failed') !== FALSE) {
         return Nette\Database\ForeignKeyConstraintViolationException::from($e);
     } else {
         return Nette\Database\ConstraintViolationException::from($e);
     }
 }
示例#18
0
 public function convertException(\PDOException $e)
 {
     $code = isset($e->errorInfo[0]) ? $e->errorInfo[0] : NULL;
     if ($code === '0A000' && strpos($e->getMessage(), 'truncate') !== FALSE) {
         return Nette\Database\ForeignKeyConstraintViolationException::from($e);
     } elseif ($code === '23502') {
         return Nette\Database\NotNullConstraintViolationException::from($e);
     } elseif ($code === '23503') {
         return Nette\Database\ForeignKeyConstraintViolationException::from($e);
     } elseif ($code === '23505') {
         return Nette\Database\UniqueConstraintViolationException::from($e);
     } elseif ($code === '08006') {
         return Nette\Database\ConnectionException::from($e);
     } else {
         return Nette\Database\DriverException::from($e);
     }
 }
示例#19
0
 /**
  * Constructor
  *
  * @param \PDOException $e      PDO exception
  * @param string        $query  SQL query OPTIONAL
  * @param array         $params SQL query parameters OPTIONAL
  *
  * @return void
  */
 public function __construct(\PDOException $e, $query = null, array $params = array())
 {
     $code = $e->getCode();
     $message = $e->getMessage();
     // Remove user credentials
     if (strstr($message, 'SQLSTATE[') && preg_match('/SQLSTATE\\[(\\w+)\\] \\[(\\w+)\\] (.*)/', $message, $matches)) {
         $code = 'HT000' == $matches[1] ? $matches[2] : $matches[1];
         $message = $matches[3];
     }
     // Add additional information
     if ($query) {
         $message .= PHP_EOL . 'SQL query: ' . $query;
     }
     if ($params) {
         $message .= PHP_EOL . 'SQL query parameters: ' . var_export($params, true);
     }
     $this->code = intval($code);
     $this->message = $message;
 }
示例#20
0
 public static function convertPDOException(\PDOException $e)
 {
     $exceptions = array('\\Psc\\Doctrine\\ForeignKeyConstraintException', '\\Psc\\Doctrine\\UniqueConstraintException', '\\Psc\\Doctrine\\TooManyConnectionsException', '\\Psc\\Doctrine\\UnknownColumnException');
     /* grml. fix pdo */
     if ($e->errorInfo === NULL && mb_strlen($msg = $e->getMessage()) > 0) {
         //SQLSTATE[08004] [1040] Too many connections
         if (\Psc\Preg::match($msg, '/SQLSTATE\\[([0-9]+)\\]\\s*\\[([0-9]+)\\]\\s*(.*)?/s', $m)) {
             $e->errorInfo[0] = $m[1];
             $e->errorInfo[1] = $m[2];
             $e->errorInfo[2] = $m[3];
         }
     }
     foreach ($exceptions as $cname) {
         if ($cname::check($e)) {
             return new $cname($e);
         }
     }
     //throw new \Psc\Exception('unconverted PDO Exception: '.Code::varInfo($e->errorInfo),0,$e);
     print 'unconverted PDOException: ' . Code::varInfo($e->errorInfo);
     return $e;
 }
示例#21
0
 /**
  * Run RAW Query
  *
  * @param string $sql
  * @return Zend_Db_Statement_Interface
  * @throws PDOException
  */
 public function raw_query($sql)
 {
     $lostConnectionMessage = 'SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query';
     $tries = 0;
     do {
         $retry = false;
         try {
             $result = $this->query($sql);
         } catch (Exception $e) {
             // Convert to PDOException to maintain backwards compatibility with usage of MySQL adapter
             if ($e instanceof Zend_Db_Statement_Exception) {
                 $e = $e->getPrevious();
                 if (!$e instanceof PDOException) {
                     $e = new PDOException($e->getMessage(), $e->getCode());
                 }
             }
             // Check to reconnect
             if ($tries < 10 && $e->getMessage() == $lostConnectionMessage) {
                 $retry = true;
                 $tries++;
             } else {
                 throw $e;
             }
         }
     } while ($retry);
     return $result;
 }
示例#22
0
文件: Statement.php 项目: taq/pdooci
 /**
  * Execute statement
  *
  * @param mixed $values optional values
  *
  * @return this object
  * @throws \PDOException
  */
 public function execute($values = null)
 {
     $ok = false;
     set_error_handler(array($this->_pdooci, "errorHandler"));
     try {
         $auto = $this->_pdooci->getAutoCommit() ? \OCI_COMMIT_ON_SUCCESS : \OCI_NO_AUTO_COMMIT;
         if ($values && sizeof($values) > 0) {
             foreach ($values as $key => $val) {
                 $parm = $key;
                 if (preg_match('/^\\d+$/', $key)) {
                     $parm++;
                 }
                 $this->bindParam($parm, $values[$key]);
                 $this->_pdooci->setError();
             }
         }
         $ok = \oci_execute($this->_stmt, $auto);
         if (!$ok) {
             $this->_pdooci->setError($this->_stmt);
             $error = $this->_pdooci->errorInfo();
             throw new \PDOException($error[2]);
         } else {
             if (count($this->_bindsLob)) {
                 foreach ($this->_bindsLob as $param => $bind) {
                     $ok = $bind['lob']->save($bind['value']);
                     if (!$ok) {
                         $error = $this->_pdooci->errorInfo();
                         $e = new \PDOException($error[2], $error[1]);
                         $e->errorInfo = $error;
                         throw $e;
                     }
                 }
             }
         }
     } catch (\PDOException $e) {
         throw $e;
     } catch (\Exception $e) {
         throw new \PDOException($e->getMessage());
     }
     restore_error_handler();
     return $ok;
 }
示例#23
0
文件: core.php 项目: umaxfun/x4m
 public function __construct(PDOException $e)
 {
     if (method_exists($this, $method = 'code' . $e->getCode())) {
         return call_user_func_array(array($this, $method), array($e));
     } else {
         die($e->getMessage());
     }
 }
示例#24
0
 /**
  * Convenience method to display a PDOException.
  *
  * @param PDOException $error
  * @return void
  */
 public function pdoError(PDOException $error)
 {
     $url = $this->controller->request->here();
     $code = 500;
     $this->controller->response->statusCode($code);
     $this->controller->set(array('code' => $code, 'url' => h($url), 'name' => $error->getMessage(), 'error' => $error));
     try {
         $this->_outputMessage($this->template);
     } catch (Exception $e) {
         $this->_outputMessageSafe('error500');
     }
 }
示例#25
0
 /**
  * Wraps and re-throws any PDO exception thrown by static::query().
  *
  * @param \PDOException $e
  *   The exception thrown by static::query().
  * @param $query
  *   The query executed by static::query().
  * @param array $args
  *   An array of arguments for the prepared statement.
  * @param array $options
  *   An associative array of options to control how the query is run.
  *
  * @return \Drupal\Core\Database\StatementInterface|int|null
  *   Most database drivers will return NULL when a PDO exception is thrown for
  *   a query, but some of them may need to re-run the query, so they can also
  *   return a \Drupal\Core\Database\StatementInterface object or an integer.
  *
  * @throws \Drupal\Core\Database\DatabaseExceptionWrapper
  * @throws \Drupal\Core\Database\IntegrityConstraintViolationException
  */
 protected function handleQueryException(\PDOException $e, $query, array $args = array(), $options = array())
 {
     if ($options['throw_exception']) {
         // Wrap the exception in another exception, because PHP does not allow
         // overriding Exception::getMessage(). Its message is the extra database
         // debug information.
         $query_string = $query instanceof StatementInterface ? $query->getQueryString() : $query;
         $message = $e->getMessage() . ": " . $query_string . "; " . print_r($args, TRUE);
         // Match all SQLSTATE 23xxx errors.
         if (substr($e->getCode(), -6, -3) == '23') {
             $exception = new IntegrityConstraintViolationException($message, $e->getCode(), $e);
         } else {
             $exception = new DatabaseExceptionWrapper($message, 0, $e);
         }
         throw $exception;
     }
     return NULL;
 }
示例#26
0
 /**
  * Run RAW Query
  *
  * @param string $sql
  * @return StatementInterface
  * @throws \PDOException
  */
 public function rawQuery($sql)
 {
     try {
         $result = $this->query($sql);
     } catch (InvalidArgumentException $e) {
         // Convert to \PDOException to maintain backwards compatibility with usage of MySQL adapter
         $e = $e->getPrevious();
         if (!$e instanceof \PDOException) {
             $e = new \PDOException($e->getMessage(), $e->getCode());
         }
         throw $e;
     }
     return $result;
 }
示例#27
0
 public function __construct(\PDOException $exception, array $config, $sql, $code = 10501)
 {
     $error = $exception->errorInfo;
     $this->setData('PDO Error Info', array('SQLSTATE' => $error[0], 'Driver Error Code' => $error[1], 'Driver Error Message' => isset($error[2]) ? $error[2] : ''));
     parent::__construct($exception->getMessage(), $config, $sql, $code);
 }
示例#28
0
 /**
  * Convenience method to display a PDOException.
  *
  * @param PDOException $error
  * @return void
  */
 public function pdoError(PDOException $error)
 {
     $url = $this->controller->request->here();
     $code = 500;
     $this->controller->response->statusCode($code);
     $this->controller->set(array('code' => $code, 'url' => h($url), 'name' => h($error->getMessage()), 'error' => $error, '_serialize' => array('code', 'url', 'name', 'error')));
     $this->_outputMessage($this->template);
 }
示例#29
0
 protected function LastError()
 {
     if (isset($this->lastException)) {
         return $this->lastException->getMessage();
     } else {
         return parent::LastError();
     }
 }
 /**
  * Write session data.
  *
  * @param      string A session ID.
  * @param      string A serialized chunk of session data.
  *
  * @return     bool true, if the session was written, otherwise an exception
  *                  is thrown.
  *
  * @throws     <b>AgaviDatabaseException</b> If session data cannot be
  *                                           written.
  *
  * @author     Sean Kerr <*****@*****.**>
  * @author     Veikko Mäkinen <*****@*****.**>
  * @author     Dominik del Bondio <*****@*****.**>
  * @since      0.11.0
  */
 public function sessionWrite($id, $data)
 {
     if (!$this->connection) {
         return false;
     }
     // get table/column
     $db_table = $this->getParameter('db_table');
     $db_data_col = $this->getParameter('db_data_col', 'sess_data');
     $db_id_col = $this->getParameter('db_id_col', 'sess_id');
     $db_time_col = $this->getParameter('db_time_col', 'sess_time');
     $isOracle = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oracle';
     $useLob = $this->getParameter('data_as_lob', true);
     $columnType = $isOracle || $useLob ? PDO::PARAM_LOB : PDO::PARAM_STR;
     if ($isOracle) {
         $sp = fopen('php://memory', 'r+');
         fwrite($sp, $data);
         rewind($sp);
     } else {
         $sp = $data;
     }
     $ts = date($this->getParameter('date_format', 'U'));
     if (is_numeric($ts)) {
         $ts = (int) $ts;
     }
     try {
         // pretend the session does not exist and attempt to create it first
         $sql = sprintf('INSERT INTO %s (%s, %s, %s) VALUES (:id, :data, :time)', $db_table, $db_id_col, $db_data_col, $db_time_col);
         $stmt = $this->connection->prepare($sql);
         $stmt->bindParam(':id', $id);
         $stmt->bindParam(':data', $sp, $columnType);
         if (is_int($ts)) {
             $stmt->bindValue(':time', $ts, PDO::PARAM_INT);
         } else {
             $stmt->bindValue(':time', $ts, PDO::PARAM_STR);
         }
         $this->connection->beginTransaction();
         if (!$stmt->execute()) {
             $errorInfo = $stmt->errorInfo();
             $e = new PDOException($errorInfo[2], $errorInfo[0]);
             $e->errorInfo = $errorInfo;
             throw $e;
         }
         if (!$this->connection->commit()) {
             $errorInfo = $stmt->errorInfo();
             $e = new PDOException($errorInfo[2], $errorInfo[0]);
             $e->errorInfo = $errorInfo;
             throw $e;
         }
     } catch (PDOException $e) {
         // something went wrong; probably a key collision, which means this session already exists
         $this->connection->rollback();
         if ($isOracle) {
             $sql = sprintf('UPDATE %s SET %s = EMPTY_BLOB(), %s = :time WHERE %s = :id RETURNING %s INTO :data', $db_table, $db_data_col, $db_time_col, $db_id_col, $db_data_col);
         } else {
             $sql = sprintf('UPDATE %s SET %s = :data, %s = :time WHERE %s = :id', $db_table, $db_data_col, $db_time_col, $db_id_col);
         }
         $stmt = $this->connection->prepare($sql);
         $stmt->bindParam(':data', $sp, $columnType);
         if (is_int($ts)) {
             $stmt->bindValue(':time', $ts, PDO::PARAM_INT);
         } else {
             $stmt->bindValue(':time', $ts, PDO::PARAM_STR);
         }
         $stmt->bindParam(':id', $id);
         $this->connection->beginTransaction();
         if (!$stmt->execute()) {
             $errorInfo = $stmt->errorInfo();
             $e = new PDOException($errorInfo[2], $errorInfo[0]);
             $e->errorInfo = $errorInfo;
             throw $e;
         }
         if (!$this->connection->commit()) {
             $errorInfo = $stmt->errorInfo();
             $e = new PDOException($errorInfo[2], $errorInfo[0]);
             $e->errorInfo = $errorInfo;
             throw $e;
         }
     } catch (PDOException $e) {
         $this->connection->rollback();
         $error = sprintf('PDOException was thrown when trying to manipulate session data. Message: "%s"', $e->getMessage());
         throw new AgaviDatabaseException($error);
     }
     return true;
 }