當前位置: 首頁>>代碼示例>>PHP>>正文


PHP QueryBuilder::createPositionalParameter方法代碼示例

本文整理匯總了PHP中Doctrine\DBAL\Query\QueryBuilder::createPositionalParameter方法的典型用法代碼示例。如果您正苦於以下問題:PHP QueryBuilder::createPositionalParameter方法的具體用法?PHP QueryBuilder::createPositionalParameter怎麽用?PHP QueryBuilder::createPositionalParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\DBAL\Query\QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder::createPositionalParameter方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __invoke

 /**
  * @param QueryBuilder $builder
  * @param $column
  * @param $value
  * @throws Exception
  * @return string
  */
 public function __invoke(QueryBuilder $builder, $column, $value)
 {
     if (is_array($value) && !empty($value)) {
         return $column . ' NOT IN (' . $builder->createPositionalParameter($value, Connection::PARAM_STR_ARRAY) . ')';
     }
     if ($value === null || is_array($value) && empty($value)) {
         return $column . ' IS NOT NULL';
     }
     return $column . ' != ' . $builder->createPositionalParameter($value);
 }
開發者ID:vlucas,項目名稱:spot2,代碼行數:17,代碼來源:Not.php

示例2: __invoke

 /**
  * @param QueryBuilder $builder
  * @param $column
  * @param $value
  * @throws Exception
  * @return string
  */
 public function __invoke(QueryBuilder $builder, $column, $value)
 {
     if (!is_array($value)) {
         throw new Exception("Use of IN operator expects value to be array. Got " . gettype($value) . ".");
     }
     return $column . ' IN (' . $builder->createPositionalParameter($value, Connection::PARAM_STR_ARRAY) . ')';
 }
開發者ID:vlucas,項目名稱:spot2,代碼行數:14,代碼來源:In.php

示例3: createPositionalParameterDelegatesToConcreteQueryBuilder

 /**
  * @test
  */
 public function createPositionalParameterDelegatesToConcreteQueryBuilder()
 {
     $this->concreteQueryBuilder->createPositionalParameter(5, Argument::cetera())->shouldBeCalled()->willReturn('?');
     $this->subject->createPositionalParameter(5);
 }
開發者ID:dachcom-digital,項目名稱:TYPO3.CMS,代碼行數:8,代碼來源:QueryBuilderTest.php

示例4: testCreatePositionalParameter

 public function testCreatePositionalParameter()
 {
     $qb = new QueryBuilder($this->conn);
     $qb->select('u.*')->from('users', 'u')->where($qb->expr()->eq('u.name', $qb->createPositionalParameter(10, \PDO::PARAM_INT)));
     $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string) $qb);
     $this->assertEquals(10, $qb->getParameter(1));
 }
開發者ID:robertowest,項目名稱:CuteFlow-V4,代碼行數:7,代碼來源:QueryBuilderTest.php

示例5: __invoke

 /**
  * @param QueryBuilder $builder
  * @param $column
  * @param $value
  * @return string
  */
 public function __invoke(QueryBuilder $builder, $column, $value)
 {
     return $column . ' >= ' . $builder->createPositionalParameter($value);
 }
開發者ID:vlucas,項目名稱:spot2,代碼行數:10,代碼來源:GreaterThanOrEqual.php

示例6: createPositionalParameter

 /**
  * Creates a new positional parameter and bind the given value to it.
  *
  * Attention: If you are using positional parameters with the query builder you have
  * to be very careful to bind all parameters in the order they appear in the SQL
  * statement , otherwise they get bound in the wrong order which can lead to serious
  * bugs in your code.
  *
  * Example:
  * <code>
  *  $qb = $conn->getQueryBuilder();
  *  $qb->select('u.*')
  *     ->from('users', 'u')
  *     ->where('u.username = ' . $qb->createPositionalParameter('Foo', IQueryBuilder::PARAM_STR))
  *     ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', IQueryBuilder::PARAM_STR))
  * </code>
  *
  * @param mixed $value
  * @param integer $type
  *
  * @return IParameter
  */
 public function createPositionalParameter($value, $type = IQueryBuilder::PARAM_STR)
 {
     return new Parameter($this->queryBuilder->createPositionalParameter($value, $type));
 }
開發者ID:rchicoli,項目名稱:owncloud-core,代碼行數:26,代碼來源:QueryBuilder.php

示例7: __invoke

 /**
  * @param QueryBuilder $builder
  * @param $column
  * @param $value
  * @return string
  */
 public function __invoke(QueryBuilder $builder, $column, $value)
 {
     return 'MATCH(' . $column . ') AGAINST (' . $builder->createPositionalParameter($value) . ')';
 }
開發者ID:vlucas,項目名稱:spot2,代碼行數:10,代碼來源:FullText.php

示例8: createPositionalParameter

 /**
  * Creates a new positional parameter and bind the given value to it.
  *
  * @param mixed   $value
  * @param integer $type
  *
  * @return string
  */
 public function createPositionalParameter($value, $type = \PDO::PARAM_STR)
 {
     return $this->qb->createPositionalParameter($value, $type);
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:12,代碼來源:SqlQueryBuilder.php


注:本文中的Doctrine\DBAL\Query\QueryBuilder::createPositionalParameter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。