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


PHP IDBConnection::getQueryBuilder方法代码示例

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


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

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

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

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

示例4: testSharesNonExistingParent

 /**
  * Test remove shares where the parent share does not exist anymore
  */
 public function testSharesNonExistingParent()
 {
     $qb = $this->connection->getQueryBuilder();
     $shareValues = ['share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_USER), 'share_with' => $qb->expr()->literal('recipientuser1'), 'uid_owner' => $qb->expr()->literal('user1'), 'item_type' => $qb->expr()->literal('folder'), 'item_source' => $qb->expr()->literal(123), 'item_target' => $qb->expr()->literal('/123'), 'file_source' => $qb->expr()->literal(123), 'file_target' => $qb->expr()->literal('/test'), 'permissions' => $qb->expr()->literal(1), 'stime' => $qb->expr()->literal(time()), 'expiration' => $qb->expr()->literal('2015-09-25 00:00:00')];
     // valid share
     $qb = $this->connection->getQueryBuilder();
     $qb->insert('share')->values($shareValues)->execute();
     $parent = $this->getLastShareId();
     // share with existing parent
     $qb = $this->connection->getQueryBuilder();
     $qb->insert('share')->values(array_merge($shareValues, ['parent' => $qb->expr()->literal($parent)]))->execute();
     $validChild = $this->getLastShareId();
     // share with non-existing parent
     $qb = $this->connection->getQueryBuilder();
     $qb->insert('share')->values(array_merge($shareValues, ['parent' => $qb->expr()->literal($parent + 100)]))->execute();
     $invalidChild = $this->getLastShareId();
     $query = $this->connection->getQueryBuilder();
     $result = $query->select('id')->from('share')->orderBy('id', 'ASC')->execute();
     $rows = $result->fetchAll();
     $this->assertEquals([['id' => $parent], ['id' => $validChild], ['id' => $invalidChild]], $rows);
     $result->closeCursor();
     $this->repair->run();
     $query = $this->connection->getQueryBuilder();
     $result = $query->select('id')->from('share')->orderBy('id', 'ASC')->execute();
     $rows = $result->fetchAll();
     $this->assertEquals([['id' => $parent], ['id' => $validChild]], $rows);
     $result->closeCursor();
 }
开发者ID:evanjt,项目名称:core,代码行数:31,代码来源:repairinvalidsharestest.php

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

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

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

示例8: tearDown

 public function tearDown()
 {
     $builder = $this->connection->getQueryBuilder();
     $builder->delete('mounts')->execute();
     $builder = $this->connection->getQueryBuilder();
     foreach ($this->fileIds as $fileId) {
         $builder->delete('filecache')->where($builder->expr()->eq('fileid', new Literal($fileId)))->execute();
     }
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:9,代码来源:UserMountCacheTest.php

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

示例10: cleanUserTags

 /**
  * Deleting orphaned user tag mappings
  *
  * @return int Number of deleted entries
  */
 protected function cleanUserTags()
 {
     $subQuery = $this->connection->getQueryBuilder();
     $subQuery->select($subQuery->expr()->literal('1'))->from('filecache', 'f')->where($subQuery->expr()->eq('objid', 'f.fileid'));
     $query = $this->connection->getQueryBuilder();
     $deletedEntries = $query->delete('vcategory_to_object')->where($query->expr()->eq('type', $query->expr()->literal('files')))->andWhere($query->expr()->isNull($query->createFunction('(' . $subQuery->getSql() . ')')))->execute();
     $this->logger->debug("{$deletedEntries} orphaned user tag relations deleted", ['app' => 'DeleteOrphanedTagsJob']);
     return $deletedEntries;
 }
开发者ID:matthias-g,项目名称:core,代码行数:14,代码来源:deleteorphanedtagsjob.php

示例11: testDeleteSubAdmin

 public function testDeleteSubAdmin()
 {
     $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
     $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[0]));
     $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[0]));
     // DB query should be empty
     $qb = $this->dbConn->getQueryBuilder();
     $result = $qb->select(['gid', 'uid'])->from('group_admin')->where($qb->expr()->eq('gid', $qb->createNamedParameter($this->groups[0]->getGID())))->andWHere($qb->expr()->eq('uid', $qb->createNamedParameter($this->users[0]->getUID())))->execute()->fetch();
     $this->assertEmpty($result);
 }
开发者ID:nem0xff,项目名称:core,代码行数:10,代码来源:subadmin.php

示例12: createShare

 /**
  * @param string $shareType
  * @param string $shareWith
  * @param null|int $parent
  * @return int
  */
 protected function createShare($shareType, $shareWith, $parent)
 {
     $qb = $this->connection->getQueryBuilder();
     $shareValues = ['share_type' => $qb->expr()->literal($shareType), 'share_with' => $qb->expr()->literal($shareWith), 'uid_owner' => $qb->expr()->literal('user1'), 'item_type' => $qb->expr()->literal('folder'), 'item_source' => $qb->expr()->literal(123), 'item_target' => $qb->expr()->literal('/123'), 'file_source' => $qb->expr()->literal(123), 'file_target' => $qb->expr()->literal('/test'), 'permissions' => $qb->expr()->literal(1), 'stime' => $qb->expr()->literal(time()), 'expiration' => $qb->expr()->literal('2015-09-25 00:00:00')];
     if ($parent) {
         $shareValues['parent'] = $qb->expr()->literal($parent);
     }
     $qb = $this->connection->getQueryBuilder();
     $qb->insert('share')->values($shareValues)->execute();
     return $this->connection->lastInsertId('*PREFIX*share');
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:17,代码来源:OldGroupMembershipSharesTest.php

示例13: removeContactShares

 /**
  * @param IOutput $output
  */
 private function removeContactShares(IOutput $output)
 {
     $qb = $this->connection->getQueryBuilder();
     $qb->delete('share')->where($qb->expr()->eq('item_type', $qb->createNamedParameter('contact')));
     $qb->execute();
     $output->advance();
     $qb = $this->connection->getQueryBuilder();
     $qb->delete('share')->where($qb->expr()->eq('item_type', $qb->createNamedParameter('addressbook')));
     $qb->execute();
     $output->advance();
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:14,代码来源:RemoveOldShares.php

示例14: testStore

 public function testStore()
 {
     $this->assertFalse($this->loader->exists('testing/mymimetype'));
     $mimetypeId = $this->loader->getId('testing/mymimetype');
     $qb = $this->db->getQueryBuilder();
     $qb->select('mimetype')->from('mimetypes')->where($qb->expr()->eq('id', $qb->createPositionalParameter($mimetypeId)));
     $mimetype = $qb->execute()->fetch();
     $this->assertEquals('testing/mymimetype', $mimetype['mimetype']);
     $this->assertEquals('testing/mymimetype', $this->loader->getMimetypeById($mimetypeId));
     $this->assertEquals($mimetypeId, $this->loader->getId('testing/mymimetype'));
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:11,代码来源:LoaderTest.php

示例15: tearDown

 public function tearDown()
 {
     $sql = $this->connection->getQueryBuilder();
     $sql->delete('appconfig');
     $sql->execute();
     $sql = $this->connection->getQueryBuilder();
     $sql->insert('appconfig')->values(['appid' => $sql->createParameter('appid'), 'configkey' => $sql->createParameter('configkey'), 'configvalue' => $sql->createParameter('configvalue')]);
     foreach ($this->originalConfig as $configs) {
         $sql->setParameter('appid', $configs['appid'])->setParameter('configkey', $configs['configkey'])->setParameter('configvalue', $configs['configvalue']);
         $sql->execute();
     }
     $this->registerAppConfig(new \OC\AppConfig(\OC::$server->getDatabaseConnection()));
     parent::tearDown();
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:14,代码来源:AppConfigTest.php


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