]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix doc blocks of insertIfNotExists() method
authorJoas Schilling <nickvergessen@owncloud.com>
Wed, 11 Mar 2015 08:00:47 +0000 (09:00 +0100)
committerJoas Schilling <nickvergessen@owncloud.com>
Wed, 11 Mar 2015 08:05:30 +0000 (09:05 +0100)
lib/private/appframework/db/db.php
lib/private/db/adapter.php
lib/private/db/adaptersqlite.php
lib/private/db/connection.php
lib/public/db.php
lib/public/idbconnection.php

index 18c32c948c54a73cb12ad365c306d46fa6f6ca4f..0824e108f49b0ffd924aa252886a1b9ca941bf99 100644 (file)
@@ -121,24 +121,16 @@ class Db implements IDb {
        }
 
        /**
-        * Insert a row if a matching row doesn't exists.
-        * @param string $table The table name (will replace *PREFIX*) to perform the replace on.
-        * @param array $input
-        * @throws \OC\HintException
-        *
-        * The input array if in the form:
-        *
-        * array ( 'id' => array ( 'value' => 6,
-        *      'key' => true
-        *      ),
-        *      'name' => array ('value' => 'Stoyan'),
-        *      'family' => array ('value' => 'Stefanov'),
-        *      'birth_date' => array ('value' => '1975-06-20')
-        *      );
-        * @return bool
+        * Insert a row if the matching row does not exists.
         *
+        * @param string $table The table name (will replace *PREFIX* with the actual prefix)
+        * @param array $input data that should be inserted into the table  (column name => value)
+        * @param array|null $compare List of values that should be checked for "if not exists"
+        *                              If this is null or an empty array, all keys of $input will be compared
+        * @return int number of inserted rows
+        * @throws \Doctrine\DBAL\DBALException
         */
-       public function insertIfNotExist($table, $input, $compare = null) {
+       public function insertIfNotExist($table, $input, array $compare = null) {
                return $this->connection->insertIfNotExist($table, $input, $compare);
        }
 
index bd1604caf2048dc14babe1643d19ecf20966d974..d0641f113f3c53020231e2e7c70a4c475b4e3e2c 100644 (file)
@@ -40,13 +40,16 @@ 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
+        * Insert a row if the matching row does not exists.
+        *
+        * @param string $table The table name (will replace *PREFIX* with the actual prefix)
+        * @param array $input data that should be inserted into the table  (column name => value)
+        * @param array|null $compare List of values that should be checked for "if not exists"
+        *                              If this is null or an empty array, all keys of $input will be compared
+        * @return int number of inserted rows
         * @throws \Doctrine\DBAL\DBALException
-        * @return int count of inserted rows
         */
-       public function insertIfNotExist($table, $input, $compare = null) {
+       public function insertIfNotExist($table, $input, array $compare = null) {
                if ($compare === null) {
                        $compare = array_keys($input);
                }
index f93183bee908ea6301e050ca9d81228ee2ef7c2c..1528285e11a7b05dfc84786787b9b4f77377c8f6 100644 (file)
@@ -19,13 +19,16 @@ class AdapterSqlite extends Adapter {
        }
 
        /**
-        * @param string $table
-        * @param array $input
-        * @param null $compare
-        * @return int
+        * Insert a row if the matching row does not exists.
+        *
+        * @param string $table The table name (will replace *PREFIX* with the actual prefix)
+        * @param array $input data that should be inserted into the table  (column name => value)
+        * @param array|null $compare List of values that should be checked for "if not exists"
+        *                              If this is null or an empty array, all keys of $input will be compared
+        * @return int number of inserted rows
         * @throws \Doctrine\DBAL\DBALException
         */
-       public function insertIfNotExist($table, $input, $compare = null) {
+       public function insertIfNotExist($table, $input, array $compare = null) {
                if ($compare === null) {
                        $compare = array_keys($input);
                }
index cdbfc94a0393e44689edca1b1a9a329cc0721c9a..023e265f242d5bf109e7e71f7ab72f6d6fa187a0 100644 (file)
@@ -157,14 +157,16 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection {
        }
 
        /**
-        * 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 field name/value pairs
-        * @param array $compare
+        * Insert a row if the matching row does not exists.
+        *
+        * @param string $table The table name (will replace *PREFIX* with the actual prefix)
+        * @param array $input data that should be inserted into the table  (column name => value)
+        * @param array|null $compare List of values that should be checked for "if not exists"
+        *                              If this is null or an empty array, all keys of $input will be compared
+        * @return int number of inserted rows
         * @throws \Doctrine\DBAL\DBALException
-        * @return bool The return value from execute()
         */
-       public function insertIfNotExist($table, $input, $compare = null) {
+       public function insertIfNotExist($table, $input, array $compare = null) {
                return $this->adapter->insertIfNotExist($table, $input, $compare);
        }
 
index d8d81f239b276270ed39291de84a6732830188f7..595ecd66bdcd8db75c57a91faf1700d94ad03de7 100644 (file)
@@ -48,23 +48,17 @@ class DB {
        }
 
        /**
-        * Insert a row if a matching row doesn't exists.
-        * @param string $table The optional table name (will replace *PREFIX*) and add sequence suffix
-        * @param array $input
-        *
-        * The input array if in the form:
+        * Insert a row if the matching row does not exists.
         *
-        * array ( 'id' => array ( 'value' => 6,
-        *      'key' => true
-        *      ),
-        *      'name' => array ('value' => 'Stoyan'),
-        *      'family' => array ('value' => 'Stefanov'),
-        *      'birth_date' => array ('value' => '1975-06-20')
-        *      );
-        * @return bool
+        * @param string $table The table name (will replace *PREFIX* with the actual prefix)
+        * @param array $input data that should be inserted into the table  (column name => value)
+        * @param array|null $compare List of values that should be checked for "if not exists"
+        *                              If this is null or an empty array, all keys of $input will be compared
+        * @return int number of inserted rows
+        * @throws \Doctrine\DBAL\DBALException
         *
         */
-       public static function insertIfNotExist($table, $input, $compare = null) {
+       public static function insertIfNotExist($table, $input, array $compare = null) {
                return \OC::$server->getDatabaseConnection()->insertIfNotExist($table, $input, $compare);
        }
 
index c8a2c5796b52ac395b72dec2a5e80c590806fd6a..1117c2da9b20b5906ac3cb6e34cf426b1f262db0 100644 (file)
@@ -77,24 +77,16 @@ interface IDBConnection {
        public function lastInsertId($table = null);
 
        /**
-        * Insert a row if a matching row doesn't exists.
-        * @param string $table The table name (will replace *PREFIX*) to perform the replace on.
-        * @param array $input
-        * @throws \Doctrine\DBAL\DBALException
-        *
-        * The input array if in the form:
-        *
-        * array ( 'id' => array ( 'value' => 6,
-        *      'key' => true
-        *      ),
-        *      'name' => array ('value' => 'Stoyan'),
-        *      'family' => array ('value' => 'Stefanov'),
-        *      'birth_date' => array ('value' => '1975-06-20')
-        *      );
-        * @return bool
+        * Insert a row if the matching row does not exists.
         *
+        * @param string $table The table name (will replace *PREFIX* with the actual prefix)
+        * @param array $input data that should be inserted into the table  (column name => value)
+        * @param array|null $compare List of values that should be checked for "if not exists"
+        *                              If this is null or an empty array, all keys of $input will be compared
+        * @return int number of inserted rows
+        * @throws \Doctrine\DBAL\DBALException
         */
-       public function insertIfNotExist($table, $input, $compare = null);
+       public function insertIfNotExist($table, $input, array $compare = null);
 
        /**
         * Start a transaction