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


PHP EntityManagerInterface::createQuery方法代码示例

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


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

示例1: testImportExport

 /**
  * @medium
  */
 public function testImportExport()
 {
     $sourceStorage = new LocalFileStorage(new \SplFileInfo(__DIR__ . '/../../../metadata/testfiles/100.csv'), new CsvFormat());
     $targetStorage = new DoctrineStorage(self::$em, 'TestEntities\\Address');
     $this->assertEquals(new StorageInfo(['name' => 'SELECT o FROM TestEntities\\Address o', 'count' => 0, 'type' => 'DQL Query']), $targetStorage->info());
     $importer = Importer::build($targetStorage);
     $importConfiguration = new ImportConfiguration();
     $importRun = $importConfiguration->toRun();
     $import = Import::build($importer, $sourceStorage, $importRun);
     $eventDispatcher = new EventDispatcher();
     $importRunner = new ImportRunner(new DefaultWorkflowFactory($eventDispatcher));
     $importRunner->run($import);
     $entities = self::$em->getRepository('TestEntities\\Address')->findAll();
     //import worked
     $this->assertEquals(100, count($entities));
     $exportFile = '/tmp/doctrine_test.csv';
     @unlink($exportFile);
     $sourceStorage = new DoctrineStorage(self::$em, null, self::$em->createQuery("SELECT A FROM TestEntities\\Address A WHERE A.zip LIKE '2%'"));
     $this->assertEquals(new StorageInfo(['name' => "SELECT A FROM TestEntities\\Address A WHERE A.zip LIKE '2%'", 'count' => 10, 'type' => 'DQL Query']), $sourceStorage->info());
     $targetStorage = new LocalFileStorage(new \SplFileInfo($exportFile), new CsvFormat());
     $importer = Importer::build($targetStorage);
     $importConfiguration = new ImportConfiguration();
     $importRun = $importConfiguration->toRun();
     $import = Import::build($importer, $sourceStorage, $importRun);
     $eventDispatcher = new EventDispatcher();
     $importRunner = new ImportRunner(new DefaultWorkflowFactory($eventDispatcher));
     $importRunner->run($import);
     $this->assertFileExists($exportFile);
     $this->assertEquals(11, count(file($exportFile)));
     //+header
     $this->assertEquals(10, $import->getRun()->toArray()['statistics']['processed']);
 }
开发者ID:mathielen,项目名称:import-engine,代码行数:35,代码来源:DoctrineTest.php

示例2: startJobs

 /**
  * {@inheritdoc}
  */
 public function startJobs(ProjectInterface $project)
 {
     $query = 'UPDATE Worldia\\Bundle\\TextmasterBundle\\Entity\\Job j ' . 'SET j.status = :status ' . 'WHERE j.projectId = :projectId ';
     $q = $this->entityManager->createQuery($query)->setParameter('status', JobInterface::STATUS_STARTED)->setParameter('projectId', $project->getId());
     $q->execute();
     $this->entityManager->clear();
 }
开发者ID:worldia,项目名称:textmaster-bundle,代码行数:10,代码来源:JobManager.php

示例3: fillData

 private function fillData()
 {
     self::$data = [];
     $q = $this->entityManager->createQuery("select partial c.{id,name,value} from ItBlaster\\SingleConfigBundle\\Entity\\Config c");
     $res = $q->execute(null, Query::HYDRATE_ARRAY);
     foreach ($res as $k => $v) {
         self::$data[$v['name']] = $v['value'];
     }
 }
开发者ID:it-blaster,项目名称:single-config-bundle,代码行数:9,代码来源:ConfigService.php

示例4: it_performs_a_fulltext_query

 public function it_performs_a_fulltext_query(EntityManagerInterface $entityManager, AbstractQuery $query, $result = [])
 {
     $entityManager->createQuery(Argument::any())->shouldBeCalled()->willReturn($query);
     $query->setParameter(Argument::any(), Argument::any())->shouldBeCalled()->willReturn($query);
     $query->getResult()->shouldBeCalled()->willReturn($result);
     $this->query('black', $entityManager)->shouldBeArray();
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:7,代码来源:OrmFinderSpec.php

示例5: uniqueNameExists

 /**
  * @param $fileName
  * @return bool
  */
 protected function uniqueNameExists($fileName, EntityManagerInterface $em)
 {
     $dql = "SELECT COUNT(image) FROM EDVFileBundle:EdImage AS image WHERE image.hashString = :name";
     $query = $em->createQuery($dql)->setParameters(array('name' => $fileName));
     $result = $query->getSingleScalarResult();
     return $result > 0;
 }
开发者ID:vlatosev,项目名称:filebundle,代码行数:11,代码来源:ImageManager.php

示例6: import

 /**
  * @param Supplier $supplier
  * @param EntityManagerInterface $entityManager
  * @return null
  */
 public function import(Supplier $supplier, EntityManagerInterface $entityManager)
 {
     $params = array('input/webpage/url' => $this->url, '_user' => $this->importIoConfig['user_id'], '_apikey' => $this->importIoConfig['api_key']);
     $result = $this->DataSource->query($this->importIoConfig['connectorGuid'], $params);
     if ($result = json_decode($result)) {
         // delete all supplier products
         $entityManager->createQuery('DELETE ProductBundle:Product p WHERE p.supplier = :supplier')->setParameter('supplier', $supplier)->execute();
         $this->createProducts($entityManager, $supplier, $result);
     }
 }
开发者ID:ernestre,项目名称:illuminati,代码行数:15,代码来源:CiliPicaProductProvider.php

示例7: existsAnyShipmentOption

 public function existsAnyShipmentOption()
 {
     $query = $this->entityManager->createQuery('SELECT 1 FROM ShoPHP\\Shipment\\ShipmentPersonalPoint');
     $query->setMaxResults(1);
     if (count($query->getResult()) > 0) {
         return true;
     }
     $query = $this->entityManager->createQuery('SELECT 1 FROM ShoPHP\\Shipment\\ShipmentCollectionPoint');
     $query->setMaxResults(1);
     if (count($query->getResult()) > 0) {
         return true;
     }
     $query = $this->entityManager->createQuery('SELECT 1 FROM ShoPHP\\Shipment\\ShipmentTransportCompany');
     $query->setMaxResults(1);
     if (count($query->getResult()) > 0) {
         return true;
     }
     return false;
 }
开发者ID:shophp,项目名称:shophp,代码行数:19,代码来源:ShipmentService.php

示例8: clearDb

 protected function clearDb()
 {
     // We can't rely on FK delete cascade as long as we're using sqlite for
     // tests. Doctrine doesn't enable FK support for it.
     $this->em->createQuery('delete from common\\entities\\Outpost')->execute();
     $this->em->createQuery('delete from common\\entities\\CelestialBody')->execute();
     $this->em->createQuery('delete from common\\entities\\System')->execute();
     $this->em->createQuery('delete from common\\entities\\Galaxy')->execute();
     $this->em->createQuery('delete from common\\entities\\CelestialBodyTypeSpecs')->execute();
     $this->em->createQuery('delete from common\\entities\\Universe')->execute();
     $this->em->createQuery('delete from common\\entities\\User')->execute();
     $this->em->flush();
 }
开发者ID:iw-reload,项目名称:iw,代码行数:13,代码来源:TestCase.php

示例9: getQuery

 /**
  * Constructs a Query instance from the current specifications of the builder.
  *
  * <code>
  *     $qb = $em->createQueryBuilder()
  *         ->select('u')
  *         ->from('User', 'u');
  *     $q = $qb->getQuery();
  *     $results = $q->execute();
  * </code>
  *
  * @return Query
  */
 public function getQuery()
 {
     $parameters = clone $this->parameters;
     $query = $this->_em->createQuery($this->getDQL())->setParameters($parameters)->setFirstResult($this->_firstResult)->setMaxResults($this->_maxResults);
     if ($this->lifetime) {
         $query->setLifetime($this->lifetime);
     }
     if ($this->cacheMode) {
         $query->setCacheMode($this->cacheMode);
     }
     if ($this->cacheable) {
         $query->setCacheable($this->cacheable);
     }
     if ($this->cacheRegion) {
         $query->setCacheRegion($this->cacheRegion);
     }
     return $query;
 }
开发者ID:Dren-x,项目名称:mobitnew,代码行数:31,代码来源:QueryBuilder.php

示例10: getAll

 /**
  * @return Order[]|\Traversable
  */
 public function getAll($limit, $offset)
 {
     $query = $this->entityManager->createQuery(sprintf('SELECT o FROM %s o', Order::class));
     $query->setFirstResult($offset)->setMaxResults($limit);
     return new Paginator($query);
 }
开发者ID:shophp,项目名称:shophp,代码行数:9,代码来源:OrderService.php

示例11: __invoke

 public function __invoke()
 {
     $query = $this->em->createQuery('SELECT b.title, COUNT(a) as authorsCount FROM AppBundle:Book b LEFT JOIN AppBundle:Author a WITH b MEMBER OF a.books');
     return $query->getResult();
 }
开发者ID:Gorik,项目名称:Doctrine2-Relations,代码行数:5,代码来源:BooksWithAuthorsCount.php

示例12: createQuery

 /**
  * {@inheritdoc}
  */
 public function createQuery($dql = '')
 {
     return $this->wrapped->createQuery($dql);
 }
开发者ID:Dren-x,项目名称:mobitnew,代码行数:7,代码来源:EntityManagerDecorator.php

示例13: queryEntity

 private function queryEntity(EntityManagerInterface $em, $label)
 {
     $times = 100;
     $size = 500;
     $startPersist = microtime(true);
     echo PHP_EOL . $label;
     for ($i = 0; $i < $size; $i++) {
         $em->persist(new Country("Country {$i}"));
     }
     $em->flush();
     $em->clear();
     printf("\n[%s] persist %s countries", number_format(microtime(true) - $startPersist, 6), $size);
     $dql = 'SELECT c FROM Doctrine\\Tests\\Models\\Cache\\Country c WHERE c.name LIKE :name';
     $startFind = microtime(true);
     for ($i = 0; $i < $times; $i++) {
         $em->createQuery($dql)->setParameter('name', "%Country%")->setCacheable(true)->getResult();
     }
     printf("\n[%s] select %s countries (%s times)", number_format(microtime(true) - $startFind, 6), $size, $times);
     printf("\n%s\n", str_repeat('-', 50));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:20,代码来源:SecondLevelCacheTest.php

示例14: count

 /**
  * @return  Integer
  */
 public function count()
 {
     return $this->entityManager->createQuery("SELECT COUNT('e') FROM " . $this->getEntity() . " e")->getSingleScalarResult();
 }
开发者ID:mkbrv,项目名称:laravel-doctrine-project,代码行数:7,代码来源:AbstractRepository.php

示例15: getResultsCount

 /**
  * Gets total results count.
  *
  * @param array $query
  *
  * @return int
  */
 private function getResultsCount($query)
 {
     $queryObject = $this->entityManager->createQuery(str_replace('SELECT ' . $this->select, 'SELECT COUNT(p.id) cnt', $query['query']));
     $queryObject->setParameters($query['parameters']);
     return $queryObject->getSingleScalarResult();
 }
开发者ID:mvar,项目名称:filtered-list-bundle,代码行数:13,代码来源:ListManager.php


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