当前位置: 首页>>代码示例>>PHP>>正文


PHP IDBConnection::executeUpdate方法代码示例

本文整理汇总了PHP中OCP\IDBConnection::executeUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP IDBConnection::executeUpdate方法的具体用法?PHP IDBConnection::executeUpdate怎么用?PHP IDBConnection::executeUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\IDBConnection的用法示例。


在下文中一共展示了IDBConnection::executeUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRun

 public function testRun()
 {
     $userName = 'removePropertiesUser';
     $data = [[$userName, '/abc.def.txt', '{DAV:}getetag', 'abcdef'], [$userName, '/abc.def.txt', '{DAV:}anotherRandomProperty', 'ghi']];
     // insert test data
     $sqlToInsertProperties = 'INSERT INTO `*PREFIX*properties` (`userid`, `propertypath`, `propertyname`, `propertyvalue`) VALUES (?, ?, ? ,?)';
     foreach ($data as $entry) {
         $this->connection->executeUpdate($sqlToInsertProperties, $entry);
     }
     // check if test data is written to DB
     $sqlToFetchProperties = 'SELECT `userid`, `propertypath`, `propertyname`, `propertyvalue` FROM `*PREFIX*properties` WHERE `userid` = ?';
     $stmt = $this->connection->executeQuery($sqlToFetchProperties, [$userName]);
     $entries = $stmt->fetchAll(\PDO::FETCH_NUM);
     $this->assertCount(2, $entries, 'Asserts that two entries are returned as we have inserted two');
     foreach ($entries as $entry) {
         $this->assertTrue(in_array($entry, $data), 'Asserts that the entries are the ones from the test data set');
     }
     /** @var IOutput | \PHPUnit_Framework_MockObject_MockObject $outputMock */
     $outputMock = $this->getMockBuilder('\\OCP\\Migration\\IOutput')->disableOriginalConstructor()->getMock();
     // run repair step
     $repair = new RemoveGetETagEntries($this->connection);
     $repair->run($outputMock);
     // check if test data is correctly modified in DB
     $stmt = $this->connection->executeQuery($sqlToFetchProperties, [$userName]);
     $entries = $stmt->fetchAll(\PDO::FETCH_NUM);
     $this->assertCount(1, $entries, 'Asserts that only one entry is returned after the repair step - the other one has to be removed');
     $this->assertSame($data[1], $entries[0], 'Asserts that the returned entry is the correct one from the test data set');
     // remove test data
     $sqlToRemoveProperties = 'DELETE FROM `*PREFIX*properties` WHERE `userid` = ?';
     $this->connection->executeUpdate($sqlToRemoveProperties, [$userName]);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:31,代码来源:RemoveGetETagEntriesTest.php

示例2: testClearFiles

 /**
  * Test clearing orphaned files
  */
 public function testClearFiles()
 {
     $input = $this->getMockBuilder('Symfony\\Component\\Console\\Input\\InputInterface')->disableOriginalConstructor()->getMock();
     $output = $this->getMockBuilder('Symfony\\Component\\Console\\Output\\OutputInterface')->disableOriginalConstructor()->getMock();
     $this->loginAsUser($this->user1);
     $view = new \OC\Files\View('/' . $this->user1 . '/');
     $view->mkdir('files/test');
     $fileInfo = $view->getFileInfo('files/test');
     $storageId = $fileInfo->getStorage()->getId();
     $this->assertCount(1, $this->getFile($fileInfo->getId()), 'Asserts that file is available');
     $this->command->execute($input, $output);
     $this->assertCount(1, $this->getFile($fileInfo->getId()), 'Asserts that file is still available');
     $deletedRows = $this->connection->executeUpdate('DELETE FROM `*PREFIX*storages` WHERE `id` = ?', [$storageId]);
     $this->assertNotNull($deletedRows, 'Asserts that storage got deleted');
     $this->assertSame(1, $deletedRows, 'Asserts that storage got deleted');
     // parent folder, `files`, ´test` and `welcome.txt` => 4 elements
     $output->expects($this->once())->method('writeln')->with('4 orphaned file cache entries deleted');
     $this->command->execute($input, $output);
     $this->assertCount(0, $this->getFile($fileInfo->getId()), 'Asserts that file gets cleaned up');
     // since we deleted the storage it might throw a (valid) StorageNotAvailableException
     try {
         $view->unlink('files/test');
     } catch (StorageNotAvailableException $e) {
     }
 }
开发者ID:nem0xff,项目名称:core,代码行数:28,代码来源:deleteorphanedfilestest.php

示例3: releaseLock

 /**
  * @param string $path
  * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  */
 public function releaseLock($path, $type)
 {
     // we DONT keep shared locks till the end of the request
     if ($type === self::LOCK_SHARED) {
         $this->db->executeUpdate('UPDATE `*PREFIX*file_locks` SET `lock` = 0 WHERE `key` = ? AND `lock` = 1', [$path]);
     }
     parent::releaseLock($path, $type);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:12,代码来源:fakedblockingprovider.php

示例4: createDBUser

 /**
  * @param IDBConnection $connection
  * @throws \OC\DatabaseSetupException
  */
 private function createDBUser($connection)
 {
     $name = $this->dbUser;
     $password = $this->dbPassword;
     // we need to create 2 accounts, one for global use and one for local user. if we don't specify the local one,
     // the anonymous user would take precedence when there is one.
     $query = "CREATE USER '{$name}'@'localhost' IDENTIFIED BY '{$password}'";
     $connection->executeUpdate($query);
     $query = "CREATE USER '{$name}'@'%' IDENTIFIED BY '{$password}'";
     $connection->executeUpdate($query);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:15,代码来源:MySQL.php

示例5: tearDown

 protected function tearDown()
 {
     $this->connection->executeUpdate('DELETE FROM `*PREFIX*share`');
     $userManager = \OC::$server->getUserManager();
     $user1 = $userManager->get($this->user1);
     if ($user1) {
         $user1->delete();
     }
     $user2 = $userManager->get($this->user2);
     if ($user2) {
         $user2->delete();
     }
     $this->logout();
     parent::tearDown();
 }
开发者ID:jincreator,项目名称:core,代码行数:15,代码来源:expiresharesjobtest.php

示例6: testGetUsersForUserValue

	public function testGetUsersForUserValue() {
		// mock the check for the database to run the correct SQL statements for each database type
		$systemConfig = $this->getMock('\OC\SystemConfig');
		$systemConfig->expects($this->once())
			->method('getValue')
			->with($this->equalTo('dbtype'),
				$this->equalTo('sqlite'))
			->will($this->returnValue(\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite')));
		$config = $this->getConfig($systemConfig);

		// preparation - add something to the database
		$data = array(
			array('user1', 'appFetch9', 'keyFetch9', 'value9'),
			array('user2', 'appFetch9', 'keyFetch9', 'value9'),
			array('user3', 'appFetch9', 'keyFetch9', 'value8'),
			array('user4', 'appFetch9', 'keyFetch8', 'value9'),
			array('user5', 'appFetch8', 'keyFetch9', 'value9'),
			array('user6', 'appFetch9', 'keyFetch9', 'value9'),
		);
		foreach ($data as $entry) {
			$this->connection->executeUpdate(
				'INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, ' .
				'`configkey`, `configvalue`) VALUES (?, ?, ?, ?)',
				$entry
			);
		}

		$value = $config->getUsersForUserValue('appFetch9', 'keyFetch9', 'value9');
		$this->assertEquals(array('user1', 'user2', 'user6'), $value);

		// cleanup
		$this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`');
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:33,代码来源:allconfig.php

示例7: updateProperties

 /**
  * Update properties
  *
  * @param Node $node node for which to update properties
  * @param array $properties array of properties to update
  *
  * @return bool
  */
 private function updateProperties($node, $properties)
 {
     $path = $node->getPath();
     $deleteStatement = 'DELETE FROM `*PREFIX*properties`' . ' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?';
     $insertStatement = 'INSERT INTO `*PREFIX*properties`' . ' (`userid`,`propertypath`,`propertyname`,`propertyvalue`) VALUES(?,?,?,?)';
     $updateStatement = 'UPDATE `*PREFIX*properties` SET `propertyvalue` = ?' . ' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?';
     // TODO: use "insert or update" strategy ?
     $existing = $this->getProperties($node, array());
     $this->connection->beginTransaction();
     foreach ($properties as $propertyName => $propertyValue) {
         // If it was null, we need to delete the property
         if (is_null($propertyValue)) {
             if (array_key_exists($propertyName, $existing)) {
                 $this->connection->executeUpdate($deleteStatement, array($this->user, $path, $propertyName));
             }
         } else {
             if (!array_key_exists($propertyName, $existing)) {
                 $this->connection->executeUpdate($insertStatement, array($this->user, $path, $propertyName, $propertyValue));
             } else {
                 $this->connection->executeUpdate($updateStatement, array($propertyValue, $this->user, $path, $propertyName));
             }
         }
     }
     $this->connection->commit();
     unset($this->cache[$path]);
     return true;
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:35,代码来源:CustomPropertiesBackend.php

示例8: createStorage

 /**
  * Create a storage entry
  *
  * @param string $storageId
  * @return int
  */
 private function createStorage($storageId)
 {
     $sql = 'INSERT INTO `*PREFIX*storages` (`id`)' . ' VALUES (?)';
     $storageId = Storage::adjustStorageId($storageId);
     $numRows = $this->connection->executeUpdate($sql, array($storageId));
     $this->assertEquals(1, $numRows);
     return \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*storages');
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:14,代码来源:repairlegacystorage.php

示例9: createStorage

 /**
  * Create a storage entry
  *
  * @param string $storageId
  * @return int
  */
 private function createStorage($storageId)
 {
     $sql = 'INSERT INTO `*PREFIX*storages` (`id`)' . ' VALUES (?)';
     $storageId = Storage::adjustStorageId($storageId);
     $numRows = $this->connection->executeUpdate($sql, array($storageId));
     $this->assertEquals(1, $numRows);
     return \OC_DB::insertid('*PREFIX*storages');
 }
开发者ID:evanjt,项目名称:core,代码行数:14,代码来源:repairlegacystorage.php

示例10: deleteAppFromAllUsers

 /**
  * Delete all user related values of one app
  *
  * @param string $appName the appName of the app that we want to remove all values from
  */
 public function deleteAppFromAllUsers($appName)
 {
     // TODO - FIXME
     $this->fixDIInit();
     $sql = 'DELETE FROM `*PREFIX*preferences` ' . 'WHERE `appid` = ?';
     $this->connection->executeUpdate($sql, array($appName));
     foreach ($this->userCache as &$userCache) {
         unset($userCache[$appName]);
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:15,代码来源:allconfig.php

示例11: releaseAll

 /**
  * release all lock acquired by this instance which were marked using the mark* methods
  */
 public function releaseAll()
 {
     parent::releaseAll();
     // since we keep shared locks we need to manually clean those
     foreach ($this->sharedLocks as $path => $lock) {
         if ($lock) {
             $this->connection->executeUpdate('UPDATE `*PREFIX*file_locks` SET `lock` = `lock` - 1 WHERE `key` = ? AND `lock` > 0', [$path]);
         }
     }
 }
开发者ID:evanjt,项目名称:core,代码行数:13,代码来源:dblockingprovider.php

示例12: cleanExpiredLocks

 /**
  * cleanup empty locks
  */
 public function cleanExpiredLocks()
 {
     $expire = $this->timeFactory->getTime();
     try {
         $this->connection->executeUpdate('DELETE FROM `*PREFIX*file_locks` WHERE `ttl` < ?', [$expire]);
     } catch (\Exception $e) {
         // If the table is missing, the clean up was successful
         if ($this->connection->tableExists('file_locks')) {
             throw $e;
         }
     }
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:15,代码来源:DBLockingProvider.php

示例13: updatePath

 /**
  * Update music path
  */
 public function updatePath($path, $userId = null)
 {
     // TODO currently this function is quite dumb
     // it just drops all entries of an user from the tables
     if ($userId === null) {
         $userId = $this->userId;
     }
     $sqls = array('DELETE FROM `*PREFIX*music_tracks` WHERE `user_id` = ?;', 'DELETE FROM `*PREFIX*music_albums` WHERE `user_id` = ?;', 'DELETE FROM `*PREFIX*music_artists` WHERE `user_id` = ?;');
     foreach ($sqls as $sql) {
         $this->db->executeUpdate($sql, array($userId));
     }
     $this->db->executeUpdate('DELETE FROM `*PREFIX*music_album_artists` WHERE `album_id` NOT IN (SELECT `id` FROM `*PREFIX*music_albums` GROUP BY `id`);');
 }
开发者ID:amin-hedayati,项目名称:music,代码行数:16,代码来源:scanner.php

示例14: cleanEmptyLocks

 /**
  * cleanup empty locks
  */
 public function cleanEmptyLocks()
 {
     $this->connection->executeUpdate('DELETE FROM `*PREFIX*file_locks` WHERE `lock` = 0');
 }
开发者ID:rosarion,项目名称:core,代码行数:7,代码来源:dblockingprovider.php

示例15: owncloud_reset_encrypted_flag

/**
 * @param \OCP\IDBConnection $conn
 */
function owncloud_reset_encrypted_flag(\OCP\IDBConnection $conn)
{
    $conn->executeUpdate('UPDATE `*PREFIX*filecache` SET `encrypted` = 0 WHERE `encrypted` = 1');
}
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:7,代码来源:update.php


注:本文中的OCP\IDBConnection::executeUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。