*/
public static function getErrorMessage($error) {
if (self::$connection) {
- $msg = self::$connection->errorCode() . ': ';
- $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 self::$connection->getError();
}
-
return '';
}
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 );