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


PHP ObjectManager::createQuery方法代码示例

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


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

示例1: findOneByAssetAndDimensions

 /**
  * Returns a thumbnail of the given asset with the specified dimensions.
  *
  * @param AssetInterface $asset The asset to render a thumbnail for
  * @param string $ratioMode The thumbnail's ratio mode, see ImageInterface::RATIOMODE_* constants
  * @param integer $maximumWidth The thumbnail's maximum width in pixels
  * @param integer $maximumHeight The thumbnail's maximum height in pixels
  * @param boolean $allowUpScaling Whether the resulting image should be upscaled
  * @return \TYPO3\Media\Domain\Model\Thumbnail The thumbnail or NULL
  */
 public function findOneByAssetAndDimensions(AssetInterface $asset, $ratioMode, $maximumWidth = NULL, $maximumHeight = NULL, $allowUpScaling = NULL)
 {
     /**
      * @var $query \Doctrine\ORM\Query
      */
     $query = $this->entityManager->createQuery('SELECT t FROM TYPO3\\Media\\Domain\\Model\\Thumbnail t WHERE t.originalAsset = :originalAsset AND t.ratioMode = :ratioMode');
     $query->setParameter('originalAsset', $this->persistenceManager->getIdentifierByObject($asset));
     $query->setParameter('ratioMode', $ratioMode);
     if ($maximumWidth !== NULL) {
         $query->setDQL($query->getDQL() . ' AND t.maximumWidth = :maximumWidth');
         $query->setParameter('maximumWidth', $maximumWidth);
     } else {
         $query->setDQL($query->getDQL() . ' AND t.maximumWidth IS NULL');
     }
     if ($maximumHeight !== NULL) {
         $query->setDQL($query->getDQL() . ' AND t.maximumHeight = :maximumHeight');
         $query->setParameter('maximumHeight', $maximumHeight);
     } else {
         $query->setDQL($query->getDQL() . ' AND t.maximumHeight IS NULL');
     }
     if ($allowUpScaling !== NULL) {
         $query->setDQL($query->getDQL() . ' AND t.allowUpScaling = :allowUpScaling');
         $query->setParameter('allowUpScaling', $allowUpScaling);
     } else {
         $query->setDQL($query->getDQL() . ' AND t.allowUpScaling IS NULL');
     }
     $query->setMaxResults(1);
     $result = $query->getOneOrNullResult();
     return $result;
 }
开发者ID:netlogix,项目名称:media,代码行数:40,代码来源:ThumbnailRepository.php

示例2: reverseTransform

 /**
  * Transforms a string (id) to an object (cathedra).
  *
  * @param string $string
  *
  * @return Cathedra|null
  *
  * @throws TransformationFailedException if object (cathedra) is not found.
  */
 public function reverseTransform($string)
 {
     if (empty($string)) {
         return null;
     }
     $cathedra = $this->om->createQuery('SELECT c FROM LearningMainBundle:Cathedra c WHERE c.title LIKE :letter')->setParameter('letter', $string)->getOneOrNullResult();
     if (null === $cathedra) {
         throw new TransformationFailedException(sprintf('Кафедра "%s" не найдена!', $string));
     }
     return $cathedra;
 }
开发者ID:Quiss,项目名称:cnmo,代码行数:20,代码来源:CathedraToStringTransformer.php

示例3: findOneByAssetAndThumbnailConfiguration

 /**
  * Returns a thumbnail of the given asset with the specified dimensions.
  *
  * @param AssetInterface $asset The asset to render a thumbnail for
  * @param ThumbnailConfiguration $configuration
  * @return \TYPO3\Media\Domain\Model\Thumbnail The thumbnail or NULL
  */
 public function findOneByAssetAndThumbnailConfiguration(AssetInterface $asset, ThumbnailConfiguration $configuration)
 {
     /**
      * @var $query \Doctrine\ORM\Query
      */
     $query = $this->entityManager->createQuery('SELECT t FROM TYPO3\\Media\\Domain\\Model\\Thumbnail t WHERE t.originalAsset = :originalAsset AND t.configurationHash = :configurationHash');
     $query->setParameter('originalAsset', $this->persistenceManager->getIdentifierByObject($asset));
     $query->setParameter('configurationHash', $configuration->getHash());
     $query->setMaxResults(1);
     $result = $query->getOneOrNullResult();
     return $result;
 }
开发者ID:hlubek,项目名称:neos-development-collection,代码行数:19,代码来源:ThumbnailRepository.php

示例4: load

 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param \Doctrine\Common\Persistence\ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $query = $manager->createQuery('SELECT COUNT(f) FROM \\Acme\\Bundle\\AppBundle\\Entity\\Fabric f');
     if (0 === $query->getSingleScalarResult()) {
         $stmt = $manager->getConnection()->prepare($this->getFabricsSql());
         $stmt->execute();
     }
     $query = $manager->createQuery('SELECT COUNT(c) FROM \\Acme\\Bundle\\AppBundle\\Entity\\Color c');
     if (0 === $query->getSingleScalarResult()) {
         $stmt = $manager->getConnection()->prepare($this->getColorSql());
         $stmt->execute();
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:18,代码来源:ReferenceDataLoader.php

示例5: isValid

 /**
  * Check if $value is valid. If it is not valid, needs to add an errorw
  * to Result.
  *
  * @param AssetInterface $value
  * @return void
  */
 protected function isValid($value)
 {
     $fileName = $value->getTitle() ?: $value->getResource()->getFilename();
     /** @var Query $query */
     $query = $this->entityManager->createQuery('SELECT a FROM TYPO3\\Media\\Domain\\Model\\Asset a JOIN a.resource r WHERE (a.title = :fileName OR r.filename = :fileName) AND a.Persistence_Object_Identifier != :assetIdentifier');
     $query->setParameter('fileName', $fileName);
     $query->setParameter('assetIdentifier', $this->persistenceManager->getIdentifierByObject($value));
     $result = $query->getArrayResult();
     // We need to exclude ImageVariant objects, but can not do that in the DQL query
     $result = array_filter($result, function ($value) {
         return $value['dtype'] !== 'typo3_media_imagevariant';
     });
     if (count($result) > 0) {
         $this->addError($this->translator->translateById('assetWithTitleAlreadyExists', [$fileName], null, $this->_localizationService->getConfiguration()->getCurrentLocale(), 'Main', 'Flownative.Neos.UniqueFilenames'), 1462705529);
     }
 }
开发者ID:flownative,项目名称:neos-uniquefilenames,代码行数:23,代码来源:UniqueFileNameValidator.php

示例6: removeAllInPath

 /**
  * Remove all nodes below a given path. Does not care about workspaces and dimensions.
  *
  * @param string $path Starting point path underneath all nodes are to be removed.
  * @return void
  */
 public function removeAllInPath($path)
 {
     $path = strtolower($path);
     $query = $this->entityManager->createQuery('DELETE FROM TYPO3\\TYPO3CR\\Domain\\Model\\NodeData n WHERE n.path LIKE :path');
     $query->setParameter('path', $path . '/%');
     $query->execute();
 }
开发者ID:testbird,项目名称:neos-development-collection,代码行数:13,代码来源:NodeDataRepository.php

示例7: reverseTransform

    /**
     * {@inheritdoc}
     */
    public function reverseTransform($value)
    {
        if (null === $value || '' === $value) {
            return null;
        }
        if (!is_string($value)) {
            throw new UnexpectedTypeException($value, 'string');
        }
        $dql = <<<DQL
SELECT i
FROM AppBundle:Core\\Invitation i
WHERE i.code = :code
AND NOT EXISTS(SELECT 1 FROM AppBundle:Core\\User u WHERE u.invitation = i)
DQL;
        return $this->em->createQuery($dql)->setParameter('code', $value)->setMaxResults(1)->getOneOrNullResult();
    }
开发者ID:hogosha,项目名称:hogosha,代码行数:19,代码来源:InvitationToCodeTransformer.php

示例8: findNextHigherIndex

 /**
  * Returns the next-higher-index seen from the given reference index in the
  * level below the specified parent path. If no node with a higher than the
  * given index exists at that level, the reference index is returned.
  *
  * The result is determined workspace-agnostic.
  *
  * @param string $parentPath Path of the parent node specifying the level in the node tree
  * @param integer $referenceIndex Index of a known node
  * @return integer The currently next higher index
  */
 protected function findNextHigherIndex($parentPath, $referenceIndex)
 {
     $this->persistEntities();
     /** @var \Doctrine\ORM\Query $query */
     $query = $this->entityManager->createQuery('SELECT MIN(n.index) FROM TYPO3\\TYPO3CR\\Domain\\Model\\NodeData n WHERE n.parentPathHash = :parentPathHash AND n.index > :referenceIndex');
     $query->setParameter('parentPathHash', md5($parentPath));
     $query->setParameter('referenceIndex', $referenceIndex);
     return $query->getSingleScalarResult() ?: NULL;
 }
开发者ID:radmiraal,项目名称:TYPO3.TYPO3CR,代码行数:20,代码来源:NodeDataRepository.php

示例9: runDql

 /**
  * Run DQL and return the result as-is.
  *
  * @param string $dql
  * @param integer $hydrationMode
  * @param integer $firstResult
  * @param integer $maxResult
  * @return mixed
  */
 public function runDql($dql, $hydrationMode = \Doctrine\ORM\Query::HYDRATE_OBJECT, $firstResult = null, $maxResult = null)
 {
     $query = $this->entityManager->createQuery($dql);
     if ($firstResult !== null) {
         $query->setFirstResult($firstResult);
     }
     if ($maxResult !== null) {
         $query->setMaxResults($maxResult);
     }
     return $query->execute(array(), $hydrationMode);
 }
开发者ID:patrickreck,项目名称:flow-development-collection,代码行数:20,代码来源:Service.php

示例10: incrementHitCount

 /**
  * @param RedirectInterface $redirect
  * @return void
  */
 public function incrementHitCount(RedirectInterface $redirect)
 {
     $host = $redirect->getHost();
     /** @var Query $query */
     if ($host === null) {
         $query = $this->entityManager->createQuery('UPDATE Neos\\RedirectHandler\\DatabaseStorage\\Domain\\Model\\Redirect r SET r.hitCounter = r.hitCounter + 1, r.lastHit = CURRENT_TIMESTAMP() WHERE r.sourceUriPath = :sourceUriPath and r.host IS NULL');
     } else {
         $query = $this->entityManager->createQuery('UPDATE Neos\\RedirectHandler\\DatabaseStorage\\Domain\\Model\\Redirect r SET r.hitCounter = r.hitCounter + 1, r.lastHit = CURRENT_TIMESTAMP() WHERE r.sourceUriPath = :sourceUriPath and r.host = :host');
         $query->setParameter('host', $host);
     }
     $query->setParameter('sourceUriPath', $redirect->getSourceUriPath())->execute();
 }
开发者ID:neos,项目名称:redirecthandler-databasestorage,代码行数:16,代码来源:RedirectRepository.php

示例11: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     /** @var EntityManager $manager */
     /** @var EntityRepository $repository */
     $repository = $manager->getRepository('OroCRMMagentoBundle:Customer');
     $queryBuilder = $repository->createQueryBuilder('customer');
     $queryBuilder->select('customer.id, SUM(customerOrder.subtotalAmount) as lifetime')->leftJoin('customer.orders', 'customerOrder', 'WITH', $queryBuilder->expr()->neq($queryBuilder->expr()->lower('customerOrder.status'), ':status'))->groupBy('customer.id')->orderBy('customer.id')->setParameter('status', Order::STATUS_CANCELED);
     $updateQuery = 'UPDATE OroCRMMagentoBundle:Customer customer SET customer.lifetime = :lifetime WHERE customer.id = :id';
     // update lifetime for all customers
     $iterator = new BufferedQueryResultIterator($queryBuilder);
     foreach ($iterator as $row) {
         $customerId = $row['id'];
         $lifetime = $row['lifetime'] ?: 0;
         $manager->createQuery($updateQuery)->setParameter('id', $customerId)->setParameter('lifetime', $lifetime)->execute();
     }
 }
开发者ID:antrampa,项目名称:crm,代码行数:19,代码来源:UpdateCustomerLifetime.php

示例12: load

 public function load(ObjectManager $manager)
 {
     $query = $manager->createQuery('SELECT i FROM GeneralBundle:Game i WHERE i.category IS NULL AND i.pair1 IS NULL AND i.pair2 IS NULL AND i.group IS NULL AND i.tournament IS NULL');
     $games = $query->getResult();
     foreach ($games as $game) {
         if ($game instanceof Game) {
             $manager->remove($game);
         }
     }
     $manager->flush();
     $repository = $manager->getRepository('GeneralBundle:Game');
     $games = $repository->findAll('TournamentName1');
     foreach ($games as $game) {
         if ($game instanceof Game) {
             $manager->remove($game);
         }
     }
     $manager->flush();
     $repository = $manager->getRepository('GeneralBundle:GroupCategory');
     $groupA = $repository->findOneByName('Group A Test');
     $groupB = $repository->findOneByName('Group B Test');
     $groupC = $repository->findOneByName('Group C Test');
     $Groups = array($groupA, $groupB, $groupC);
     $repository = $manager->getRepository('GeneralBundle:Inscription');
     foreach ($Groups as $group) {
         if ($group instanceof GroupCategory) {
             $inscriptions = $repository->findByGroup($group);
             foreach ($inscriptions as $inscription) {
                 if ($inscription instanceof Inscription) {
                     $manager->remove($inscription);
                 }
             }
         }
     }
     $manager->flush();
     $Users = array(array('email' => 'emailCategoryTest'), array('email' => 'User1Pair1'), array('email' => 'User2Pair1'), array('email' => 'User1Pair2'), array('email' => 'User2Pair2'), array('email' => 'User1Pair3'), array('email' => 'User2Pair3'), array('email' => 'User1Pair4'), array('email' => 'User2Pair4'), array('email' => 'User1Pair5'), array('email' => 'User2Pair5'), array('email' => 'User1Pair6'), array('email' => 'User2Pair6'), array('email' => 'User1Pair7'), array('email' => 'User2Pair7'), array('email' => 'User1Pair8'), array('email' => 'User2Pair8'), array('email' => 'User1Pair9'), array('email' => 'User2Pair9'), array('email' => 'User1Pair10'), array('email' => 'User2Pair10'));
     $repository = $manager->getRepository('GeneralBundle:User');
     foreach ($Users as $key) {
         $entity = $repository->findOneByEmail($key['email']);
         if ($entity instanceof User) {
             $manager->remove($entity);
         }
     }
     $manager->flush();
 }
开发者ID:albertoml,项目名称:padelTFG,代码行数:45,代码来源:GameTestRemove.php

示例13: countBy

 private function countBy($from, $to, $location, $addWhere, $datefield, $selectAndFrom, $groupAndOrder)
 {
     $constraints = array();
     $to2 = $this->getTo($from, $to);
     $constraints[] = $datefield . '>=:from';
     $params['from'] = $from;
     $constraints[] = $datefield . '<:to';
     $params['to'] = $to2;
     if (!empty($location)) {
         $constraints[] = 'a.location=:loc';
         $params['loc'] = $location;
     }
     $constraints[] = 'a.isDummy=0';
     if ($addWhere != null) {
         $constraints[] = $addWhere;
     }
     $where = ' WHERE ' . implode(' AND ', $constraints);
     $query = $this->entityManager->createQuery('SELECT ' . $selectAndFrom . ' ' . $where . ' ' . $groupAndOrder);
     $ret = $query->execute($params);
     return $ret;
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:21,代码来源:Report.php

示例14: findJohnDoe

 private function findJohnDoe(ObjectManager $manager)
 {
     $query = $manager->createQuery("SELECT u FROM Claroline\\CoreBundle\\Entity\\User u where u.username = 'JohnDoe'");
     $query->setFetchMode("MyProject\\User", "address", "EXTRA_LAZY");
     return $query->getSingleResult();
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:6,代码来源:LoadWorkspacesData.php

示例15: enableExistantUsers

 /**
  * Enable existant users
  *
  * @param Collection $users
  */
 private function enableExistantUsers(Collection $users)
 {
     $query = $this->manager->createQuery('UPDATE Beloop\\Component\\User\\Entity\\User u SET u.enabled=:enabled WHERE u.email IN (:emails)');
     $query->setParameter('enabled', true);
     $query->setParameter('emails', $this->extractEmails($users)->toArray());
 }
开发者ID:beloop,项目名称:components,代码行数:11,代码来源:UserManager.php


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