]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove OC_DB::insertid
authorMorris Jobke <hey@morrisjobke.de>
Thu, 7 Jan 2016 09:22:30 +0000 (10:22 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 7 Jan 2016 13:54:55 +0000 (14:54 +0100)
lib/private/db.php
lib/private/files/cache/storage.php
lib/private/share/share.php
tests/lib/db.php
tests/lib/repair/repairlegacystorage.php

index f5f0c8798cd37f31b7761052238fe3621a7c85b3..14d9ba0a4938bfa20b56db55b158c9557422ec83 100644 (file)
@@ -157,21 +157,6 @@ class OC_DB {
                return $result;
        }
 
-       /**
-        * gets last value of autoincrement
-        * @param string $table The optional table name (will replace *PREFIX*) and add sequence suffix
-        * @return string id
-        * @throws \OC\DatabaseException
-        *
-        * \Doctrine\DBAL\Connection lastInsertId
-        *
-        * Call this method right after the insert command or other functions may
-        * cause trouble!
-        */
-       public static function insertid($table=null) {
-               return \OC::$server->getDatabaseConnection()->lastInsertId($table);
-       }
-
        /**
         * saves database schema to xml file
         * @param string $file name of file
index cee691940953ff33d4b9e65c70ec6bac8e2213e5..e5235d1ca92d49f275b9aec21c334af69f01a24d 100644 (file)
@@ -61,7 +61,7 @@ class Storage {
                        $connection = \OC_DB::getConnection();
                        $available = $isAvailable ? 1 : 0;
                        if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId, 'available' => $available])) {
-                               $this->numericId = \OC_DB::insertid('*PREFIX*storages');
+                               $this->numericId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*storages');
                        } else {
                                if ($row = self::getStorageById($this->storageId)) {
                                        $this->numericId = $row['numeric_id'];
index b10de850356ee2a3f8bcc265d92d0b0ebb0fcc50..2b251dba1e0daf10ff17f84c12e6602dfaf004c5 100644 (file)
@@ -2191,7 +2191,7 @@ class Share extends Constants {
                if ($isGroupShare) {
                        $id = self::insertShare($queriesToExecute['groupShare']);
                        // Save this id, any extra rows for this group share will need to reference it
-                       $parent = \OC_DB::insertid('*PREFIX*share');
+                       $parent = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share');
                        unset($queriesToExecute['groupShare']);
                }
 
index 95eca4774b7dbad3e43038d969eef9c47ee2232f..88c9ee75b3be11464f26fe8d5622b9202d04659d 100644 (file)
@@ -111,11 +111,11 @@ class Test_DB extends \Test\TestCase {
        public function testLastInsertId() {
                $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)');
                $result1 = OC_DB::executeAudited($query, array('insertid 1','uri_1'));
-               $id1 = OC_DB::insertid('*PREFIX*'.$this->table2);
+               $id1 = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*'.$this->table2);
                
                // we don't know the id we should expect, so insert another row
                $result2 = OC_DB::executeAudited($query, array('insertid 2','uri_2'));
-               $id2 = OC_DB::insertid('*PREFIX*'.$this->table2);
+               $id2 = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*'.$this->table2);
                // now we can check if the two ids are in correct order
                $this->assertGreaterThan($id1, $id2);
        }
index 44afd6125abe75e778321d974cd5eb6427273726..3ae6578f7ec343fecf28407b565667b92e1bafb4 100644 (file)
@@ -99,7 +99,7 @@ class RepairLegacyStorages extends TestCase {
                $numRows = $this->connection->executeUpdate($sql, array($storageId));
                $this->assertEquals(1, $numRows);
 
-               return \OC_DB::insertid('*PREFIX*storages');
+               return \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*storages');
        }
 
        /**