本文整理汇总了PHP中Doctrine\DBAL\Query\QueryBuilder::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::getType方法的具体用法?PHP QueryBuilder::getType怎么用?PHP QueryBuilder::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Query\QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::getType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSQLDelegatesToConcreteQueryBuilder
/**
* @test
*/
public function getSQLDelegatesToConcreteQueryBuilder()
{
$this->concreteQueryBuilder->getSQL()->shouldBeCalled()->willReturn('UPDATE aTable SET pid = 7');
$this->concreteQueryBuilder->getType()->willReturn(2);
// Update Type
$this->subject->getSQL();
}
示例2: __construct
/**
* Constructor.
*
* @param QueryBuilder $queryBuilder A DBAL query builder.
* @param callable $countQueryBuilderModifier A callable to modifier the query builder to count.
*/
public function __construct(QueryBuilder $queryBuilder, $countQueryBuilderModifier)
{
if ($queryBuilder->getType() !== QueryBuilder::SELECT) {
throw new InvalidArgumentException('Only SELECT queries can be paginated.');
}
if (!is_callable($countQueryBuilderModifier)) {
throw new InvalidArgumentException('The count query builder modifier must be a callable.');
}
$this->queryBuilder = clone $queryBuilder;
$this->countQueryBuilderModifier = $countQueryBuilderModifier;
}
示例3: __construct
/**
* Constructor.
*
* @param QueryBuilder $queryBuilder A DBAL query builder.
* @param string $countField Primary key for the table in query. Used in count expression. Must include table alias
* @param boolean $useDistinct When set to true it'll count the countfield with a distinct in front of it.
*
* @api
*/
public function __construct(QueryBuilder $queryBuilder, $countField, $useDistinct = true)
{
if (strpos($countField, '.') === false) {
throw new LogicException('The $countField must contain a table alias in the string.');
}
if (QueryBuilder::SELECT !== $queryBuilder->getType()) {
throw new LogicException('Only SELECT queries can be paginated.');
}
$this->queryBuilder = $queryBuilder;
$this->countField = $countField;
$this->useDistinct = $useDistinct;
}
示例4: testEmptyDelete
public function testEmptyDelete()
{
$qb = new QueryBuilder($this->conn);
$qb2 = $qb->delete();
$this->assertEquals(QueryBuilder::DELETE, $qb->getType());
$this->assertSame($qb2, $qb);
}
示例5: testEmptyInsert
public function testEmptyInsert()
{
$qb = new QueryBuilder($this->conn);
$qb2 = $qb->insert();
$this->assertEquals(QueryBuilder::INSERT, $qb->getType());
$this->assertSame($qb2, $qb);
}
示例6: getType
/**
* Gets the type of the currently built query.
*
* @return integer
*/
public function getType()
{
return $this->queryBuilder->getType();
}
示例7: getType
/**
* Gets the type of the currently built query.
*
* @return integer
*/
public function getType()
{
return $this->qb->getType();
}
示例8: getCount
/**
* Counts the number of results that would be returned by the select query provided
*
* @param QueryBuilder $qb
* @return int
*/
public function getCount(QueryBuilder $qb)
{
if ($qb->getType() != QueryBuilder::SELECT) {
throw new \InvalidArgumentException('Query builder must be a select query');
}
$select = $qb->getQueryPart('select');
$count = (int) $qb->select('COUNT(main.id)')->execute()->fetchColumn();
$qb->select($select);
return $count;
}
示例9: generator
/**
* Generator for SELECT queries.
*
* @param \Doctrine\DBAL\Query\QueryBuilder $qb
*
* @return \Iterator
*/
protected function generator(QueryBuilder $qb)
{
if ($qb->getType() !== QueryBuilder::SELECT) {
self::raise('Generator should be used only with SELECT queries.');
}
$stmt = $this->preprocess($qb);
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$from = $join = [];
foreach ($row as $key => $value) {
// if column was preprocessed
if (false !== ($pos = strpos($key, self::UNIQUE))) {
$table = substr($key, 0, $pos);
$column = substr($key, $pos + 6);
if ($table === $this->table) {
$from[$column] = $value;
} else {
$join[$table][$column] = $value;
}
} else {
$from[$key] = $value;
}
}
$class = $this->entity;
$entity = new $class($from);
foreach ($join as $table => $data) {
// every JOIN will be set as a sub-entity
$class = $this->app['arm'][$this->prefix . $table]->getEntity();
$entity[$table] = new $class($data);
}
(yield $entity);
}
}