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


PHP Query::setParameter方法代码示例

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


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

示例1: consultaContiene

 /**
  * @param \Doctrine\ORM\Query|\Doctrine\ORM\QueryBuilder $query
  * @param array $array
  * @param string $contiene
  * @return \Doctrine\ORM\Query|\Doctrine\ORM\QueryBuilder
  */
 public function consultaContiene($query, $array, $contiene)
 {
     if ($contiene != "") {
         $fields = array_keys($this->getClassMetadata()->fieldNames);
         $alias = $query->getRootAlias();
         $count = 0;
         foreach ($array as $field) {
             $fieldMapping = $this->getClassMetadata()->getFieldForColumn($field);
             $where = sprintf("UPPER(%s.%s) LIKE :condicion", $alias, $fieldMapping);
             if ($count == 0) {
                 $query->andWhere($where);
             } else {
                 $query->orWhere($where);
             }
             $count++;
         }
         $query->setParameter("condicion", "%" . strtoupper($contiene) . "%");
     }
     return $query;
 }
开发者ID:uvillazon,项目名称:symfonysecuriy,代码行数:26,代码来源:BaseRepository.php

示例2: testApplyAnonymous

 /**
  * @covers Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper::apply
  * @covers Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper::cloneQuery
  */
 public function testApplyAnonymous()
 {
     /* @var $queryBuilder QueryBuilder */
     $queryBuilder = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
     $query = new Query($this->em);
     $query->setParameter('paramName', 'paramValue', 'paramType');
     $queryBuilder->expects($this->any())->method('getQuery')->will($this->returnValue($query));
     $queryBuilder->expects($this->once())->method('getRootEntities')->will($this->returnValue(array('Kunstmaan\\NodeBundle\\Entity\\Node')));
     $queryBuilder->expects($this->once())->method('getRootAliases')->will($this->returnValue(array('n')));
     $roles = array();
     $this->token->expects($this->once())->method('getRoles')->will($this->returnValue($roles));
     $this->rh->expects($this->once())->method('getReachableRoles')->with($roles)->will($this->returnValue($roles));
     $this->token->expects($this->any())->method('getUser')->will($this->returnValue('anon.'));
     $permissionDef = new PermissionDefinition(array('view'), 'Kunstmaan\\NodeBundle\\Entity\\Node');
     /* @var $query Query */
     $query = $this->object->apply($queryBuilder, $permissionDef);
     $this->assertEquals(MaskBuilder::MASK_VIEW, $query->getHint('acl.mask'));
     $this->assertEquals($permissionDef->getEntity(), $query->getHint('acl.root.entity'));
     $this->assertEquals('rootTable', $query->getHint('acl.entityRootTableName'));
     $this->assertEquals('n', $query->getHint('acl.entityRootTableDqlAlias'));
     $aclQuery = $query->getHint('acl.extra.query');
     $this->assertContains('"IS_AUTHENTICATED_ANONYMOUSLY"', $aclQuery);
 }
开发者ID:BranchBit,项目名称:KunstmaanBundlesCMS,代码行数:27,代码来源:AclHelperTest.php

示例3: findCollectionBreadcrumbById

 /**
  * {@inheritdoc}
  */
 public function findCollectionBreadcrumbById($id)
 {
     try {
         $sql = sprintf('SELECT n, collectionMeta, defaultMeta
              FROM %s AS p,
                   %s AS n
                     LEFT JOIN n.meta AS collectionMeta
                     LEFT JOIN n.defaultMeta AS defaultMeta
              WHERE p.id = :id AND p.lft > n.lft AND p.rgt < n.rgt
              ORDER BY n.lft', $this->_entityName, $this->_entityName);
         $query = new Query($this->_em);
         $query->setDQL($sql);
         $query->setParameter('id', $id);
         return $query->getResult();
     } catch (NoResultException $ex) {
         return [];
     }
 }
开发者ID:sulu,项目名称:sulu,代码行数:21,代码来源:CollectionRepository.php

示例4: setParameters

 /**
  * Sets parameters for the query
  *
  * @param \Doctrine\ORM\Query $query      Query to be set parameters on
  * @param array               $parameters Variables
  *
  * @return \Doctrine\ORM\Query
  *
  * @author r1pp3rj4ck <attila.bukor@gmail.com>
  */
 private function setParameters(\Doctrine\ORM\Query $query, array $parameters)
 {
     foreach ($parameters as $name => $param) {
         $query->setParameter($name, $param['value']);
     }
     return $query;
 }
开发者ID:nvdnkpr,项目名称:VelvelReportBundle,代码行数:17,代码来源:BaseReportBuilder.php

示例5: testStaticApply

 public function testStaticApply()
 {
     $staticSegmentStub = new Segment();
     $staticSegmentStub->setType(new SegmentType(SegmentType::TYPE_STATIC));
     $filterData = ['value' => $staticSegmentStub];
     $subquery = 'SELECT ts1.entity_id FROM OroSegmentBundle:SegmentSnapshot ts1 WHERE ts1.segmentId = :segment';
     $em = $this->getTestEntityManager();
     $qb = new QueryBuilder($em);
     $qb->select(['t1.name'])->from('OroSegmentBundle:CmsUser', 't1');
     $ds = new OrmFilterDatasourceAdapter($qb);
     $query = new Query($em);
     $query->setDQL($subquery);
     $query->setParameter('segment', $staticSegmentStub);
     $this->staticSegmentQueryBuilder->expects($this->once())->method('build')->with($staticSegmentStub)->will($this->returnValue($query));
     $this->filter->init('someName', [FilterUtility::DATA_NAME_KEY => self::TEST_FIELD_NAME]);
     $this->filter->apply($ds, $filterData);
     $expectedResult = ['SELECT t1.name FROM OroSegmentBundle:CmsUser t1 WHERE t1.id', 'IN(SELECT ts1.entity_id FROM OroSegmentBundle:SegmentSnapshot ts1 WHERE ts1.segmentId = :segment)'];
     $expectedResult = implode(' ', $expectedResult);
     $this->assertEquals($expectedResult, $ds->getQueryBuilder()->getDQL());
     $params = $ds->getQueryBuilder()->getParameters();
     $this->assertCount(1, $params, 'Should pass params to main query builder');
     $this->assertEquals($staticSegmentStub, $params[0]->getValue());
 }
开发者ID:xamin123,项目名称:platform,代码行数:23,代码来源:SegmentFilterTest.php

示例6: param

 /**
  * Sets params value in a query object
  *
  * @access   public
  * @param    string $sParamName
  * @param    string $mParamValue
  * @return   $this
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function param($sParamName, $mParamValue)
 {
     $this->oQuery->setParameter($sParamName, $mParamValue);
     return $this;
 }
开发者ID:ktrzos,项目名称:plethora,代码行数:15,代码来源:DB.php

示例7: testCacheMissWhenTypeChanges

 /**
  * @depends testIssue
  */
 public function testCacheMissWhenTypeChanges(Query $query)
 {
     $query->setParameter('field', 'test', 'string');
     $this->assertStringEndsWith('.field = ?', $query->getSQL());
 }
开发者ID:selimcr,项目名称:servigases,代码行数:8,代码来源:DDC2224Test.php

示例8: tagAction

    /**
     * @route: blog_tag
     * Tag Controller
     */
    public function tagAction($slug)
    {
        $em = $this->getEm();
        $query = new Query($em);
        $query->setDQL(
            'SELECT t
                FROM Bundle\BlogBundle\Entity\Tag t WHERE t.slug = ?1'
        );
        $query->setParameter(1, $slug);
        $tag = $query->getSingleResult();

        

        return $this->render('BlogBundle:Blog:tag.html.twig', array(
            'tag' => $tag,
            'posts' => $tag->getPosts()
        ));
    }
开发者ID:rdbsf,项目名称:BlogBundle,代码行数:22,代码来源:BlogController.php


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