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


PHP OCP\IDBConnection类代码示例

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


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

示例1: deleteUserMailQueue

 /**
  * Delete all mail queue entries
  *
  * @param IDBConnection $connection
  * @param string $user
  */
 protected static function deleteUserMailQueue(IDBConnection $connection, $user)
 {
     // Delete entries from mail queue
     $queryBuilder = $connection->getQueryBuilder();
     $queryBuilder->delete('activity_mq')->where($queryBuilder->expr()->eq('amq_affecteduser', $queryBuilder->createParameter('user')))->setParameter('user', $user);
     $queryBuilder->execute();
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:13,代码来源:hooks.php

示例2: testAddAccept

    function testAddAccept()
    {
        $query = $this->connection->prepare('
			INSERT INTO `*PREFIX*share_external`
			(`remote`, `share_token`, `password`, `name`, `owner`, `user`, `mountpoint`, `mountpoint_hash`, `remote_id`, `accepted`)
			VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
		');
        for ($i = 0; $i < 10; $i++) {
            $query->execute(array('remote', 'token', 'password', 'name', 'owner', 'user', 'mount point', $i, $i, 0));
        }
        $query = $this->connection->prepare('SELECT `id` FROM `*PREFIX*share_external`');
        $query->execute();
        $dummyEntries = $query->fetchAll();
        $this->assertSame(10, count($dummyEntries));
        $m = new Migration();
        $m->addAcceptRow();
        // verify result
        $query = $this->connection->prepare('SELECT `accepted` FROM `*PREFIX*share_external`');
        $query->execute();
        $results = $query->fetchAll();
        $this->assertSame(10, count($results));
        foreach ($results as $r) {
            $this->assertSame(1, (int) $r['accepted']);
        }
        // cleanup
        $cleanup = $this->connection->prepare('DELETE FROM `*PREFIX*share_external`');
        $cleanup->execute();
    }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:28,代码来源:migrationtest.php

示例3: test

 public function test()
 {
     // insert test data
     $builder = $this->db->getQueryBuilder();
     $builder->insert('contacts_addressbooks')->values(['userid' => $builder->createNamedParameter('test-user-666'), 'displayname' => $builder->createNamedParameter('Display Name'), 'uri' => $builder->createNamedParameter('contacts'), 'description' => $builder->createNamedParameter('An address book for testing'), 'ctag' => $builder->createNamedParameter('112233'), 'active' => $builder->createNamedParameter('1')])->execute();
     $builder = $this->db->getQueryBuilder();
     $builder->insert('contacts_cards')->values(['addressbookid' => $builder->createNamedParameter(6666), 'fullname' => $builder->createNamedParameter('Full Name'), 'carddata' => $builder->createNamedParameter('datadatadata'), 'uri' => $builder->createNamedParameter('some-card.vcf'), 'lastmodified' => $builder->createNamedParameter('112233')])->execute();
     $builder = $this->db->getQueryBuilder();
     $builder->insert('share')->values(['share_type' => $builder->createNamedParameter(1), 'share_with' => $builder->createNamedParameter('user01'), 'uid_owner' => $builder->createNamedParameter('user02'), 'item_type' => $builder->createNamedParameter('addressbook'), 'item_source' => $builder->createNamedParameter(6666), 'item_target' => $builder->createNamedParameter('Contacts (user02)')])->execute();
     // test the adapter
     $this->adapter->foreachBook('test-user-666', function ($row) {
         $this->books[] = $row;
     });
     $this->assertArrayHasKey('id', $this->books[0]);
     $this->assertEquals('test-user-666', $this->books[0]['userid']);
     $this->assertEquals('Display Name', $this->books[0]['displayname']);
     $this->assertEquals('contacts', $this->books[0]['uri']);
     $this->assertEquals('An address book for testing', $this->books[0]['description']);
     $this->assertEquals('112233', $this->books[0]['ctag']);
     $this->adapter->foreachCard(6666, function ($row) {
         $this->cards[] = $row;
     });
     $this->assertArrayHasKey('id', $this->cards[0]);
     $this->assertEquals(6666, $this->cards[0]['addressbookid']);
     // test getShares
     $shares = $this->adapter->getShares(6666);
     $this->assertEquals(1, count($shares));
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:28,代码来源:addressbookadaptertest.php

示例4: cleanUp

    /**
     * Removes orphaned data from the database
     */
    public function cleanUp()
    {
        $sqls = array('UPDATE `*PREFIX*music_albums` SET `cover_file_id` = NULL
				WHERE `cover_file_id` IS NOT NULL AND `cover_file_id` IN (
					SELECT `cover_file_id` FROM (
						SELECT `cover_file_id` FROM `*PREFIX*music_albums`
						LEFT JOIN `*PREFIX*filecache`
							ON `cover_file_id`=`fileid`
						WHERE `fileid` IS NULL
					) mysqlhack
				);', 'DELETE FROM `*PREFIX*music_tracks` WHERE `file_id` IN (
				SELECT `file_id` FROM (
					SELECT `file_id` FROM `*PREFIX*music_tracks`
					LEFT JOIN `*PREFIX*filecache`
						ON `file_id`=`fileid`
					WHERE `fileid` IS NULL
					) mysqlhack
				);', 'DELETE FROM `*PREFIX*music_albums` WHERE `id` NOT IN (
					SELECT `album_id` FROM `*PREFIX*music_tracks`
					GROUP BY `album_id`
				);', 'DELETE FROM `*PREFIX*music_album_artists` WHERE `album_id` NOT IN (
					SELECT `id` FROM `*PREFIX*music_albums`
					GROUP BY `id`
				);', 'DELETE FROM `*PREFIX*music_artists` WHERE `id` NOT IN (
					SELECT `artist_id` FROM `*PREFIX*music_album_artists`
					GROUP BY `artist_id`
				);');
        foreach ($sqls as $sql) {
            $query = $this->db->prepare($sql);
            $query->execute();
        }
    }
开发者ID:ndurchx,项目名称:music,代码行数:35,代码来源:helper.php

示例5: test

 public function test()
 {
     // insert test data
     $builder = $this->db->getQueryBuilder();
     $builder->insert('clndr_calendars')->values(['userid' => $builder->createNamedParameter('test-user-666'), 'displayname' => $builder->createNamedParameter('Display Name'), 'uri' => $builder->createNamedParameter('events'), 'ctag' => $builder->createNamedParameter('112233'), 'active' => $builder->createNamedParameter('1')])->execute();
     $builder = $this->db->getQueryBuilder();
     $builder->insert('clndr_objects')->values(['calendarid' => $builder->createNamedParameter(6666), 'objecttype' => $builder->createNamedParameter('VEVENT'), 'startdate' => $builder->createNamedParameter(new \DateTime(), 'datetime'), 'enddate' => $builder->createNamedParameter(new \DateTime(), 'datetime'), 'repeating' => $builder->createNamedParameter(0), 'summary' => $builder->createNamedParameter('Something crazy will happen'), 'uri' => $builder->createNamedParameter('event.ics'), 'lastmodified' => $builder->createNamedParameter('112233')])->execute();
     $builder = $this->db->getQueryBuilder();
     $builder->insert('share')->values(['share_type' => $builder->createNamedParameter(1), 'share_with' => $builder->createNamedParameter('user01'), 'uid_owner' => $builder->createNamedParameter('user02'), 'item_type' => $builder->createNamedParameter('calendar'), 'item_source' => $builder->createNamedParameter(6666), 'item_target' => $builder->createNamedParameter('Contacts (user02)')])->execute();
     // test the adapter
     $this->adapter->foreachCalendar('test-user-666', function ($row) {
         $this->cals[] = $row;
     });
     $this->assertArrayHasKey('id', $this->cals[0]);
     $this->assertEquals('test-user-666', $this->cals[0]['userid']);
     $this->assertEquals('Display Name', $this->cals[0]['displayname']);
     $this->assertEquals('events', $this->cals[0]['uri']);
     $this->assertEquals('112233', $this->cals[0]['ctag']);
     $this->adapter->foreachCalendarObject(6666, function ($row) {
         $this->calObjs[] = $row;
     });
     $this->assertArrayHasKey('id', $this->calObjs[0]);
     $this->assertEquals(6666, $this->calObjs[0]['calendarid']);
     // test getShares
     $shares = $this->adapter->getShares(6666);
     $this->assertEquals(1, count($shares));
 }
开发者ID:ZverAleksey,项目名称:core,代码行数:27,代码来源:calendaradaptertest.php

示例6: run

 public function run(IOutput $output)
 {
     $qb = $this->connection->getQueryBuilder();
     $qb->update('filecache')->set('etag', $qb->expr()->literal('xxx'))->where($qb->expr()->eq('etag', $qb->expr()->literal('')))->orWhere($qb->expr()->isNull('etag'));
     $result = $qb->execute();
     $output->info("ETags have been fixed for {$result} files/folders.");
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:7,代码来源:FillETags.php

示例7: 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

示例8: 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

示例9: cleanupRelation

 private function cleanupRelation()
 {
     $sql = 'DELETE FROM `*PREFIX*music_album_artists` ' . 'WHERE `album_id` NOT IN (SELECT `id` FROM `*PREFIX*music_albums`) ' . 'OR `artist_id` NOT IN (SELECT `id` FROM `*PREFIX*music_artists`)';
     $this->db->prepareQuery($sql)->execute();
     $sql = 'DELETE FROM `*PREFIX*music_playlist_tracks` ' . 'WHERE `track_id` NOT IN (SELECT `id` FROM `*PREFIX*music_tracks`)';
     $this->db->prepareQuery($sql)->execute();
 }
开发者ID:uycarumba,项目名称:music,代码行数:7,代码来源:resetdatabase.php

示例10: run

 public function run()
 {
     $qb = $this->connection->getQueryBuilder();
     $qb->update('filecache')->set('etag', $qb->expr()->literal('xxx'))->where($qb->expr()->eq('etag', $qb->expr()->literal('')))->orWhere($qb->expr()->isNull('etag'));
     $result = $qb->execute();
     $this->emit('\\OC\\Repair', 'info', array("ETags have been fixed for {$result} files/folders."));
 }
开发者ID:kenwi,项目名称:core,代码行数:7,代码来源:filletags.php

示例11: fixAvatarPermissions

 /**
  * Make sure all avatar files in the user roots have permission 27
  */
 protected function fixAvatarPermissions()
 {
     $qb = $this->connection->getQueryBuilder();
     $qb2 = $this->connection->getQueryBuilder();
     $qb->select('numeric_id')->from('storages')->where($qb->expr()->like('id', $qb2->createParameter('like')));
     $qb2->update('filecache')->set('permissions', $qb2->createNamedParameter(27))->where($qb2->expr()->like('path', $qb2->createNamedParameter('avatar.%')))->andWhere($qb2->expr()->in('storage', $qb2->createFunction($qb->getSQL())))->andWhere($qb2->expr()->neq('permissions', $qb2->createNamedParameter(27)))->setParameter('like', 'home::%');
     $qb2->execute();
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:11,代码来源:AvatarPermissions.php

示例12: 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

示例13: removeExpirationDateFromNonLinkShares

 /**
  * Past bugs would make it possible to set an expiration date on user shares even
  * though it is not supported. This functions removes the expiration date from such entries.
  */
 private function removeExpirationDateFromNonLinkShares()
 {
     $builder = $this->connection->getQueryBuilder();
     $builder->update('share')->set('expiration', 'null')->where($builder->expr()->isNotNull('expiration'))->andWhere($builder->expr()->neq('share_type', $builder->expr()->literal(\OC\Share\Constants::SHARE_TYPE_LINK)));
     $updatedEntries = $builder->execute();
     if ($updatedEntries > 0) {
         $this->emit('\\OC\\Repair', 'info', array('Removed invalid expiration date from ' . $updatedEntries . ' shares'));
     }
 }
开发者ID:sinozope,项目名称:core,代码行数:13,代码来源:repairinvalidshares.php

示例14: getLastShareId

 /**
  * @return int
  */
 protected function getLastShareId()
 {
     // select because lastInsertId does not work with OCI
     $query = $this->connection->getQueryBuilder();
     $result = $query->select('id')->from('share')->orderBy('id', 'DESC')->execute();
     $row = $result->fetch();
     $result->closeCursor();
     return $row['id'];
 }
开发者ID:rajeshpillai,项目名称:core,代码行数:12,代码来源:oldgroupmembershipsharestest.php

示例15: testRun

 public function testRun()
 {
     $this->assertFalse($this->connection->tableExists('sharing'), 'Asserting that the table oc_sharing does not exist before repairing');
     $this->assertTrue($this->connection->tableExists('permissions'), 'Asserting that the table oc_permissions does exist before repairing');
     $repair = new \OC\Repair\DropOldTables($this->connection);
     $repair->run();
     $this->assertFalse($this->connection->tableExists('sharing'), 'Asserting that the table oc_sharing does not exist after repairing');
     $this->assertFalse($this->connection->tableExists('permissions'), 'Asserting that the table oc_permissions does not exist after repairing');
 }
开发者ID:evanjt,项目名称:core,代码行数:9,代码来源:dropoldtables.php


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