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


PHP DocumentManager::createQueryBuilder方法代码示例

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


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

示例1: testQueryBuilder

 public function testQueryBuilder()
 {
     $strategy = new ChildTranslationStrategy($this->dm);
     $this->dm->setTranslationStrategy('children', $strategy);
     $this->dm->setLocaleChooserStrategy(new LocaleChooser(array('en' => array('fr'), 'fr' => array('en')), 'en'));
     // First save some translations
     $data = array();
     $data['topic'] = 'Some interesting subject';
     $data['text'] = 'Lorem ipsum...';
     $data['settings'] = array('is-active' => 'true', 'url' => 'great-article-in-english.html');
     $node = $this->getTestNode();
     $node->setProperty('author', 'John Doe');
     $node->setProperty('phpcr:class', 'Doctrine\\Tests\\Models\\Translation\\ChildTranslationArticle');
     $strategy->saveTranslation($data, $node, $this->metadata, 'en');
     // Save translation in another language
     $data['topic'] = 'Un sujet intéressant';
     $data['settings'] = array('is-active' => 'true', 'url' => 'super-article-en-francais.html');
     $strategy->saveTranslation($data, $node, $this->metadata, 'fr');
     $this->dm->flush();
     $qb = $this->dm->createQueryBuilder();
     $qb->from()->document('Doctrine\\Tests\\Models\\Translation\\ChildTranslationArticle', 'a');
     $qb->where()->eq()->field('a.topic')->literal('Not Exist')->end();
     $res = $qb->getQuery()->execute();
     $this->assertCount(0, $res);
     $qb = $this->dm->createQueryBuilder();
     $qb->from()->document('Doctrine\\Tests\\Models\\Translation\\ChildTranslationArticle', 'a');
     $qb->where()->eq()->field('a.topic')->literal('Un sujet intéressant')->end();
     $res = $qb->getQuery()->execute();
     $this->assertCount(0, $res);
     $qb = $this->dm->createQueryBuilder();
     $qb->setLocale(false);
     $qb->from()->document('Doctrine\\Tests\\Models\\Translation\\ChildTranslationArticle', 'a');
     $qb->where()->eq()->field('a.topic')->literal('Un sujet intéressant')->end();
     $res = $qb->getQuery()->execute();
     $this->assertCount(0, $res);
     $qb = $this->dm->createQueryBuilder();
     $qb->from()->document('Doctrine\\Tests\\Models\\Translation\\ChildTranslationArticle', 'a');
     $qb->where()->eq()->field('a.topic')->literal('Some interesting subject')->end();
     $res = $qb->getQuery()->execute();
     $this->assertCount(1, $res);
     $qb = $this->dm->createQueryBuilder();
     $qb->setLocale('fr');
     $qb->from()->document('Doctrine\\Tests\\Models\\Translation\\ChildTranslationArticle', 'a');
     $qb->where()->eq()->field('a.topic')->literal('Un sujet intéressant')->end();
     $res = $qb->getQuery()->execute();
     $this->assertCount(1, $res);
 }
开发者ID:pkdevbox,项目名称:phpcr-odm,代码行数:47,代码来源:ChildTranslationStrategyTest.php

示例2: createQuery

 /**
  * Create a Query
  *
  * @param  string $statement the SQL2 statement
  * @param  string $language (see QueryInterface for list of supported types)
  * @param  bool $replaceWithFieldnames if * should be replaced with Fieldnames automatically
  * @return PHPCR\Query\QueryResultInterface
  */
 public function createQuery($statement, $language, $options = 0)
 {
     $cb = $this->dm->createQueryBuilder()->setFromQuery($statement, $language);
     if ($options & self::QUERY_REPLACE_WITH_FIELDNAMES) {
         $columns = $cb->getColumns();
         if (1 === count($columns)) {
             $column = reset($columns);
             if ('*' === $column->getColumnName() && null == $column->getPropertyName()) {
                 $cb->setColumns(array());
                 foreach ($this->class->getFieldNames() as $name) {
                     $cb->addSelect($name);
                 }
             }
         }
     }
     $factory = $cb->getQOMFactory();
     $comparison = $factory->comparison($factory->propertyValue('phpcr:class'), Constants::JCR_OPERATOR_EQUAL_TO, $factory->literal($this->className));
     $cb->andWhere($comparison);
     return $cb->getQuery();
 }
开发者ID:richardmiller,项目名称:phpcr-odm,代码行数:28,代码来源:DocumentRepository.php

示例3: createQueryBuilder

 /**
  * Create a QueryBuilder that is pre-populated for this repositories document
  *
  * The returned query builder will be pre-populated with the criteria
  * required to search for this repositories document class.
  *
  * NOTE: When adding criteria to the query builder you should
  *       use ->andWhere(...) as ->where(...) will overwrite
  *       the class criteria.
  *
  * @param string $alias name of the alias to use, defaults to 'a'
  *
  * @return \Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder
  */
 public function createQueryBuilder($alias)
 {
     $qb = $this->dm->createQueryBuilder();
     $qb->from($alias)->document($this->className, $alias);
     return $qb;
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:20,代码来源:DocumentRepository.php

示例4: createQb

 protected function createQb()
 {
     $qb = $this->dm->createQueryBuilder();
     return $qb;
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:5,代码来源:QueryBuilderTest.php


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