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


PHP Connection::createQueryBuilder方法代码示例

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


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

示例1: run

 public function run()
 {
     $qb = $this->connection->createQueryBuilder();
     $qb->update('`*PREFIX*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:heldernl,项目名称:owncloud8-extended,代码行数:7,代码来源:filletags.php

示例2: testRemoveDeletedFiles

 /**
  * @dataProvider dataTestRemoveDeletedFiles
  * @param boolean $nodeExists
  */
 public function testRemoveDeletedFiles($nodeExists)
 {
     $this->initTable();
     $this->rootFolder->expects($this->once())->method('nodeExists')->with('/' . $this->user0 . '/files_trashbin')->willReturn($nodeExists);
     if ($nodeExists) {
         $this->rootFolder->expects($this->once())->method('get')->with('/' . $this->user0 . '/files_trashbin')->willReturn($this->rootFolder);
         $this->rootFolder->expects($this->once())->method('delete');
     } else {
         $this->rootFolder->expects($this->never())->method('get');
         $this->rootFolder->expects($this->never())->method('delete');
     }
     $this->invokePrivate($this->cleanup, 'removeDeletedFiles', [$this->user0]);
     if ($nodeExists) {
         // if the delete operation was execute only files from user1
         // should be left.
         $query = $this->dbConnection->createQueryBuilder();
         $result = $query->select('`user`')->from($this->trashTable)->execute()->fetchAll();
         $this->assertSame(5, count($result));
         foreach ($result as $r) {
             $this->assertSame('user1', $r['user']);
         }
     } else {
         // if no delete operation was execute we should still have all 10
         // database entries
         $getAllQuery = $this->dbConnection->createQueryBuilder();
         $result = $getAllQuery->select('`id`')->from($this->trashTable)->execute()->fetchAll();
         $this->assertSame(10, count($result));
     }
 }
开发者ID:ninjasilicon,项目名称:core,代码行数:33,代码来源:cleanuptest.php

示例3: updateDB

 /**
  * update database
  */
 public function updateDB()
 {
     // make sure that we don't update the file cache multiple times
     // only update during the first run
     if ($this->installedVersion === '-1') {
         return;
     }
     // delete left-over from old encryption which is no longer needed
     $this->config->deleteAppValue('files_encryption', 'ocsid');
     $this->config->deleteAppValue('files_encryption', 'types');
     $this->config->deleteAppValue('files_encryption', 'enabled');
     $oldAppValues = $this->connection->createQueryBuilder();
     $oldAppValues->select('*')->from('`*PREFIX*appconfig`')->where($oldAppValues->expr()->eq('`appid`', ':appid'))->setParameter('appid', 'files_encryption');
     $appSettings = $oldAppValues->execute();
     while ($row = $appSettings->fetch()) {
         // 'installed_version' gets deleted at the end of the migration process
         if ($row['configkey'] !== 'installed_version') {
             $this->config->setAppValue('encryption', $row['configkey'], $row['configvalue']);
             $this->config->deleteAppValue('files_encryption', $row['configkey']);
         }
     }
     $oldPreferences = $this->connection->createQueryBuilder();
     $oldPreferences->select('*')->from('`*PREFIX*preferences`')->where($oldPreferences->expr()->eq('`appid`', ':appid'))->setParameter('appid', 'files_encryption');
     $preferenceSettings = $oldPreferences->execute();
     while ($row = $preferenceSettings->fetch()) {
         $this->config->setUserValue($row['userid'], 'encryption', $row['configkey'], $row['configvalue']);
         $this->config->deleteUserValue($row['userid'], 'files_encryption', $row['configkey']);
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:32,代码来源:migration.php

示例4: removeDeletedFiles

 /**
  * remove deleted files for the given user
  *
  * @param string $uid
  */
 protected function removeDeletedFiles($uid)
 {
     \OC_Util::tearDownFS();
     \OC_Util::setupFS($uid);
     if ($this->rootFolder->nodeExists('/' . $uid . '/files_trashbin')) {
         $this->rootFolder->get('/' . $uid . '/files_trashbin')->delete();
         $query = $this->dbConnection->createQueryBuilder();
         $query->delete('`*PREFIX*files_trash`')->where($query->expr()->eq('`user`', ':uid'))->setParameter('uid', $uid);
         $query->execute();
     }
 }
开发者ID:ninjasilicon,项目名称:core,代码行数:16,代码来源:cleanup.php

示例5: deleteOrphanEntries

 /**
  * Deletes all entries from $deleteTable that do not have a matching entry in $sourceTable
  *
  * A query joins $deleteTable.$deleteId = $sourceTable.$sourceId and checks
  * whether $sourceNullColumn is null. If it is null, the entry in $deleteTable
  * is being deleted.
  *
  * @param string $repairInfo
  * @param string $deleteTable
  * @param string $deleteId
  * @param string $sourceTable
  * @param string $sourceId
  * @param string $sourceNullColumn	If this column is null in the source table,
  * 								the entry is deleted in the $deleteTable
  */
 protected function deleteOrphanEntries($repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn)
 {
     $qb = $this->connection->createQueryBuilder();
     $qb->select('d.`' . $deleteId . '`')->from('`' . $deleteTable . '`', 'd')->leftJoin('d', '`' . $sourceTable . '`', 's', 'd.`' . $deleteId . '` = s.`' . $sourceId . '`')->where('d.`type` = ' . $qb->expr()->literal('files'))->andWhere($qb->expr()->isNull('s.`' . $sourceNullColumn . '`'));
     $result = $qb->execute();
     $orphanItems = array();
     while ($row = $result->fetch()) {
         $orphanItems[] = (int) $row[$deleteId];
     }
     if (!empty($orphanItems)) {
         $orphanItemsBatch = array_chunk($orphanItems, 200);
         foreach ($orphanItemsBatch as $items) {
             $qb->delete('`' . $deleteTable . '`')->where('`type` = ' . $qb->expr()->literal('files'))->andWhere($qb->expr()->in('`' . $deleteId . '`', ':ids'));
             $qb->setParameter('ids', $items, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY);
             $qb->execute();
         }
     }
     if ($repairInfo) {
         $this->emit('\\OC\\Repair', 'info', array(sprintf($repairInfo, sizeof($orphanItems))));
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:36,代码来源:cleantags.php

示例6: updateDB

 /**
  * update database
  */
 public function updateDB()
 {
     // delete left-over from old encryption which is no longer needed
     $this->config->deleteAppValue('files_encryption', 'ocsid');
     $this->config->deleteAppValue('files_encryption', 'types');
     $this->config->deleteAppValue('files_encryption', 'enabled');
     $query = $this->connection->createQueryBuilder();
     $query->update('`*PREFIX*appconfig`')->set('`appid`', ':newappid')->where($query->expr()->eq('`appid`', ':oldappid'))->setParameter('oldappid', 'files_encryption')->setParameter('newappid', 'encryption');
     $query->execute();
     $query = $this->connection->createQueryBuilder();
     $query->update('`*PREFIX*preferences`')->set('`appid`', ':newappid')->where($query->expr()->eq('`appid`', ':oldappid'))->setParameter('oldappid', 'files_encryption')->setParameter('newappid', 'encryption');
     $query->execute();
 }
开发者ID:alfrescoo,项目名称:core,代码行数:16,代码来源:migration.php

示例7: getShareOwner

 /**
  * Retrieve the owner of a connection
  *
  * @param Connection $connection
  * @param int $shareId
  * @throws \Exception
  * @return string uid of share owner
  */
 private static function getShareOwner(Connection $connection, $shareId)
 {
     $qb = $connection->createQueryBuilder();
     $qb->select('`uid_owner`')->from('`*PREFIX*share`')->where('`id` = :shareId')->setParameter(':shareId', $shareId);
     $result = $qb->execute();
     $result = $result->fetch();
     if (empty($result)) {
         throw new \Exception('Share not found');
     }
     return $result['uid_owner'];
 }
开发者ID:julakali,项目名称:core,代码行数:19,代码来源:share.php


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