diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-07-08 07:17:45 -0700 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-07-08 07:17:45 -0700 |
commit | 02d2e41e04735e91c94864a98c5eed89b6ceb7f7 (patch) | |
tree | 6a4ed65b71f13c4680d986a8755d6c79dc0fae3d /lib | |
parent | 8d8f99fbc49b2747895743dc55d9ddf8c3aa842a (diff) | |
parent | 212ea0508d05f881d01df4f5b2ed38133bdff359 (diff) | |
download | nextcloud-server-02d2e41e04735e91c94864a98c5eed89b6ceb7f7.tar.gz nextcloud-server-02d2e41e04735e91c94864a98c5eed89b6ceb7f7.zip |
Merge pull request #3954 from owncloud/update_insertifnotexist_and_test
fix insertIfNotExist return value, update doc and corresponding test
Diffstat (limited to 'lib')
-rw-r--r-- | lib/db.php | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/db.php b/lib/db.php index a93b9eccbdf..6fec60e53ce 100644 --- a/lib/db.php +++ b/lib/db.php @@ -681,7 +681,7 @@ class OC_DB { * @brief Insert a row if a matching row doesn't exists. * @param string $table. The table to insert into in the form '*PREFIX*tableName' * @param array $input. An array of fieldname/value pairs - * @returns The return value from PDOStatementWrapper->execute() + * @returns int number of updated rows */ public static function insertIfNotExist($table, $input) { self::connect(); @@ -715,7 +715,7 @@ class OC_DB { . implode('`,`', array_keys($input)) . '`) VALUES(' . str_repeat('?,', count($input)-1).'? ' . ')'; } else { - return true; + return 0; //no rows updated } } elseif( $type == 'pgsql' || $type == 'oci' || $type == 'mysql' || $type == 'mssql') { $query = 'INSERT INTO `' .$table . '` (`' @@ -736,9 +736,6 @@ class OC_DB { } catch(PDOException $e) { OC_Template::printExceptionErrorPage( $e ); } - if ($result === 0) { - return true; - } return $result; } @@ -1036,7 +1033,7 @@ class PDOStatementWrapper{ } /** - * make execute return the result instead of a bool + * make execute return the result or updated row count instead of a bool */ public function execute($input=array()) { if(OC_Config::getValue( "log_query", false)) { |