diff options
author | Bart Visscher <bartv@thisnet.nl> | 2013-07-01 18:20:27 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2013-07-21 23:17:37 +0200 |
commit | 000b5a801f27914d0a906b5f4c6ff58e14e5aebe (patch) | |
tree | ae69a305078f66067318ffbc544eb0b774ad6160 /lib/db/connection.php | |
parent | de83bf98c759d8af9483306ddea07006693f74be (diff) | |
download | nextcloud-server-000b5a801f27914d0a906b5f4c6ff58e14e5aebe.tar.gz nextcloud-server-000b5a801f27914d0a906b5f4c6ff58e14e5aebe.zip |
Move building error string to connection
Diffstat (limited to 'lib/db/connection.php')
-rw-r--r-- | lib/db/connection.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/db/connection.php b/lib/db/connection.php index e18062d78f3..1f01fae4f71 100644 --- a/lib/db/connection.php +++ b/lib/db/connection.php @@ -148,6 +148,23 @@ class Connection extends \Doctrine\DBAL\Connection { 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 protected function replaceTablePrefix($statement) { return str_replace( '*PREFIX*', $this->table_prefix, $statement ); |