aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/db
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-03-09 22:12:31 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-03-09 22:37:49 +0100
commit89be55a672afe0e09a33d4997ec10c0e833d4885 (patch)
tree2789f398177333df179ab73fc5ad9926edce39ec /lib/private/db
parentb966a4eb17729230c461b9075143203bd50ed9e3 (diff)
downloadnextcloud-server-89be55a672afe0e09a33d4997ec10c0e833d4885.tar.gz
nextcloud-server-89be55a672afe0e09a33d4997ec10c0e833d4885.zip
let insertIfNotExist() throw the native DBALException - no need to hide the real exception
Diffstat (limited to 'lib/private/db')
-rw-r--r--lib/private/db/adapter.php17
-rw-r--r--lib/private/db/adaptersqlite.php22
-rw-r--r--lib/private/db/connection.php10
-rw-r--r--lib/private/db/mdb2schemamanager.php2
4 files changed, 16 insertions, 35 deletions
diff --git a/lib/private/db/adapter.php b/lib/private/db/adapter.php
index ee6898dde85..bd1604caf20 100644
--- a/lib/private/db/adapter.php
+++ b/lib/private/db/adapter.php
@@ -43,7 +43,7 @@ class Adapter {
* insert the @input values when they do not exist yet
* @param string $table name
* @param array $input key->value pair, key has to be sanitized properly
- * @throws \OC\HintException
+ * @throws \Doctrine\DBAL\DBALException
* @return int count of inserted rows
*/
public function insertIfNotExist($table, $input, $compare = null) {
@@ -68,19 +68,6 @@ class Adapter {
$query = substr($query, 0, strlen($query) - 5);
$query .= ' HAVING COUNT(*) = 0';
- try {
- return $this->conn->executeUpdate($query, $inserts);
- } catch(\Doctrine\DBAL\DBALException $e) {
- $entry = 'DB Error: "'.$e->getMessage() . '"<br />';
- $entry .= 'Offending command was: ' . $query.'<br />';
- \OC_Log::write('core', $entry, \OC_Log::FATAL);
- $l = \OC::$server->getL10N('lib');
- throw new \OC\HintException(
- $l->t('Database Error'),
- $l->t('Please contact your system administrator.'),
- 0,
- $e
- );
- }
+ return $this->conn->executeUpdate($query, $inserts);
}
}
diff --git a/lib/private/db/adaptersqlite.php b/lib/private/db/adaptersqlite.php
index 8b3c4ebc839..f93183bee90 100644
--- a/lib/private/db/adaptersqlite.php
+++ b/lib/private/db/adaptersqlite.php
@@ -18,6 +18,13 @@ class AdapterSqlite extends Adapter {
return $statement;
}
+ /**
+ * @param string $table
+ * @param array $input
+ * @param null $compare
+ * @return int
+ * @throws \Doctrine\DBAL\DBALException
+ */
public function insertIfNotExist($table, $input, $compare = null) {
if ($compare === null) {
$compare = array_keys($input);
@@ -40,19 +47,6 @@ class AdapterSqlite extends Adapter {
$query = substr($query, 0, strlen($query) - 5);
$query .= ')';
- try {
- return $this->conn->executeUpdate($query, $inserts);
- } catch(\Doctrine\DBAL\DBALException $e) {
- $entry = 'DB Error: "'.$e->getMessage() . '"<br />';
- $entry .= 'Offending command was: ' . $query.'<br />';
- \OC_Log::write('core', $entry, \OC_Log::FATAL);
- $l = \OC::$server->getL10N('lib');
- throw new \OC\HintException(
- $l->t('Database Error'),
- $l->t('Please contact your system administrator.'),
- 0,
- $e
- );
- }
+ return $this->conn->executeUpdate($query, $inserts);
}
}
diff --git a/lib/private/db/connection.php b/lib/private/db/connection.php
index cc94c862b85..cdbfc94a039 100644
--- a/lib/private/db/connection.php
+++ b/lib/private/db/connection.php
@@ -152,16 +152,16 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection {
}
// internal use
- public function realLastInsertId($seqName = null)
- {
+ public function realLastInsertId($seqName = null) {
return parent::lastInsertId($seqName);
}
/**
- * Insert a row if a matching row doesn't exists.
+ * Insert a row if a matching row does not exists.
* @param string $table. The table to insert into in the form '*PREFIX*tableName'
- * @param array $input. An array of fieldname/value pairs
- * @throws \OC\HintException
+ * @param array $input. An array of field name/value pairs
+ * @param array $compare
+ * @throws \Doctrine\DBAL\DBALException
* @return bool The return value from execute()
*/
public function insertIfNotExist($table, $input, $compare = null) {
diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php
index 358360d0b46..66c97f9e3b4 100644
--- a/lib/private/db/mdb2schemamanager.php
+++ b/lib/private/db/mdb2schemamanager.php
@@ -35,7 +35,7 @@ class MDB2SchemaManager {
*
* TODO: write more documentation
*/
- public function getDbStructure($file, $mode = MDB2_SCHEMA_DUMP_STRUCTURE) {
+ public function getDbStructure($file) {
return \OC_DB_MDB2SchemaWriter::saveSchemaToFile($file, $this->conn);
}