Move building error string to connection
This commit is contained in:
parent
de83bf98c7
commit
000b5a801f
10
lib/db.php
10
lib/db.php
|
@ -433,16 +433,8 @@ class OC_DB {
|
||||||
*/
|
*/
|
||||||
public static function getErrorMessage($error) {
|
public static function getErrorMessage($error) {
|
||||||
if (self::$connection) {
|
if (self::$connection) {
|
||||||
$msg = self::$connection->errorCode() . ': ';
|
return self::$connection->getError();
|
||||||
$errorInfo = self::$connection->errorInfo();
|
|
||||||
if (is_array($errorInfo)) {
|
|
||||||
$msg .= 'SQLSTATE = '.$errorInfo[0] . ', ';
|
|
||||||
$msg .= 'Driver Code = '.$errorInfo[1] . ', ';
|
|
||||||
$msg .= 'Driver Message = '.$errorInfo[2];
|
|
||||||
}
|
|
||||||
return $msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,23 @@ class Connection extends \Doctrine\DBAL\Connection {
|
||||||
return $this->adapter->insertIfNotExist($table, $input);
|
return $this->adapter->insertIfNotExist($table, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the error code and message as a string for logging
|
||||||
|
* works with DoctrineException
|
||||||
|
* @param mixed $error
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getError() {
|
||||||
|
$msg = $this->errorCode() . ': ';
|
||||||
|
$errorInfo = $this->errorInfo();
|
||||||
|
if (is_array($errorInfo)) {
|
||||||
|
$msg .= 'SQLSTATE = '.$errorInfo[0] . ', ';
|
||||||
|
$msg .= 'Driver Code = '.$errorInfo[1] . ', ';
|
||||||
|
$msg .= 'Driver Message = '.$errorInfo[2];
|
||||||
|
}
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
// internal use
|
// internal use
|
||||||
protected function replaceTablePrefix($statement) {
|
protected function replaceTablePrefix($statement) {
|
||||||
return str_replace( '*PREFIX*', $this->table_prefix, $statement );
|
return str_replace( '*PREFIX*', $this->table_prefix, $statement );
|
||||||
|
|
Loading…
Reference in New Issue