本文整理匯總了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);
}
示例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) . ')';
}
示例3: createPositionalParameterDelegatesToConcreteQueryBuilder
/**
* @test
*/
public function createPositionalParameterDelegatesToConcreteQueryBuilder()
{
$this->concreteQueryBuilder->createPositionalParameter(5, Argument::cetera())->shouldBeCalled()->willReturn('?');
$this->subject->createPositionalParameter(5);
}
示例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));
}
示例5: __invoke
/**
* @param QueryBuilder $builder
* @param $column
* @param $value
* @return string
*/
public function __invoke(QueryBuilder $builder, $column, $value)
{
return $column . ' >= ' . $builder->createPositionalParameter($value);
}
示例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));
}
示例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) . ')';
}
示例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);
}