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


PHP Connection::getQueryBuilder方法代码示例

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


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

示例1: 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->getQueryBuilder();
         $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->getQueryBuilder();
         $result = $getAllQuery->select('id')->from($this->trashTable)->execute()->fetchAll();
         $this->assertSame(10, count($result));
     }
 }
开发者ID:rosarion,项目名称:core,代码行数:33,代码来源:cleanuptest.php

示例2: copyTable

 protected function copyTable(Connection $fromDB, Connection $toDB, $table, InputInterface $input, OutputInterface $output)
 {
     $chunkSize = $input->getOption('chunk-size');
     /** @var $progress \Symfony\Component\Console\Helper\ProgressHelper */
     $progress = $this->getHelperSet()->get('progress');
     $query = $fromDB->getQueryBuilder();
     $query->automaticTablePrefix(false);
     $query->selectAlias($query->createFunction('COUNT(*)'), 'num_entries')->from($table);
     $result = $query->execute();
     $count = $result->fetchColumn();
     $result->closeCursor();
     $numChunks = ceil($count / $chunkSize);
     if ($numChunks > 1) {
         $output->writeln('chunked query, ' . $numChunks . ' chunks');
     }
     $progress->start($output, $count);
     $redraw = $count > $chunkSize ? 100 : ($count > 100 ? 5 : 1);
     $progress->setRedrawFrequency($redraw);
     $query = $fromDB->getQueryBuilder();
     $query->automaticTablePrefix(false);
     $query->select('*')->from($table)->setMaxResults($chunkSize);
     $insertQuery = $toDB->getQueryBuilder();
     $insertQuery->automaticTablePrefix(false);
     $insertQuery->insert($table);
     $parametersCreated = false;
     for ($chunk = 0; $chunk < $numChunks; $chunk++) {
         $query->setFirstResult($chunk * $chunkSize);
         $result = $query->execute();
         while ($row = $result->fetch()) {
             $progress->advance();
             if (!$parametersCreated) {
                 foreach ($row as $key => $value) {
                     $insertQuery->setValue($key, $insertQuery->createParameter($key));
                 }
                 $parametersCreated = true;
             }
             foreach ($row as $key => $value) {
                 $insertQuery->setParameter($key, $value);
             }
             $insertQuery->execute();
         }
         $result->closeCursor();
     }
     $progress->finish();
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:45,代码来源:ConvertType.php


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