本文整理汇总了PHP中Doctrine\DBAL\Query\QueryBuilder::getQueryPart方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::getQueryPart方法的具体用法?PHP QueryBuilder::getQueryPart怎么用?PHP QueryBuilder::getQueryPart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Query\QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::getQueryPart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDistinct
/**
* Returns the sql expression to determinate the distincts numbers of lines
*
* @return string
*/
protected function getDistinct()
{
if (isset($this->conf->group)) {
return $this->conf->group;
}
return implode(', ', $this->queryBuilder->getQueryPart('select'));
}
示例2: getTotal
/**
* @return bool|string
*/
public function getTotal()
{
if ($this->total) {
return $this->total;
}
$queryBuilder = $this->repository->getEm()->createQueryBuilder();
$fromParts = $this->queryBuilder->getQueryPart('from');
if ($fromParts) {
foreach ($fromParts as $from) {
$queryBuilder->from($from['table'], $from['alias']);
}
}
$queryBuilder->select('COUNT(*)');
$where = $this->queryBuilder->getQueryPart('where');
if ($where) {
$queryBuilder->add('where', (string) $where);
}
$parameters = $this->queryBuilder->getParameters();
if ($parameters) {
foreach ($parameters as $key => $value) {
$queryBuilder->setParameter($key, $value);
}
}
return $this->total = $queryBuilder->execute()->fetchColumn();
}
示例3: hasJoinAlias
/**
* {@inheritDoc}
*/
public function hasJoinAlias($joinAlias)
{
$joinParts = $this->queryBuilder->getQueryPart('join');
foreach ($joinParts as $rootAlias => $joins) {
foreach ($joins as $join) {
if ($join['joinAlias'] === $joinAlias) {
return true;
}
}
}
return false;
}
示例4: incorporateDbalQueryBuilder
/**
* @internal
*/
private function incorporateDbalQueryBuilder(QueryBuilder $qb, FilterInterface $filter)
{
$criteria = $this->getFilteringCriteria($filter);
// extraindo os rootAliases, pois o DBAL\QueryBuilder não tem
$fromPart = $qb->getQueryPart('from');
$rootAliases = array();
foreach ($fromPart as $part) {
$rootAliases[] = $part['alias'];
}
$visitor = new DbalQueryExpressionVisitor($qb->getConnection(), $rootAliases, $this->fieldMap);
if ($whereExpression = $criteria->getWhereExpression()) {
$qb->andWhere($visitor->dispatch($whereExpression));
$qb->setParameters($visitor->getParameters());
}
if ($criteria->getOrderings()) {
foreach ($criteria->getOrderings() as $sort => $order) {
$qb->addOrderBy($visitor->getFieldName($sort), $order);
}
}
if (($firstResult = $criteria->getFirstResult()) !== null) {
$qb->setFirstResult($firstResult);
}
if (($maxResults = $criteria->getMaxResults()) !== null) {
$qb->setMaxResults($maxResults);
}
}
示例5: load
/**
* For repeating fields, the load method adds extra joins and selects to the query that
* fetches the related records from the field and field value tables in the same query as the content fetch.
*
* @param QueryBuilder $query
* @param ClassMetadata $metadata
*
* @return void
*/
public function load(QueryBuilder $query, ClassMetadata $metadata)
{
$field = $this->mapping['fieldname'];
$boltname = $metadata->getBoltName();
$from = $query->getQueryPart('from');
if (isset($from[0]['alias'])) {
$alias = $from[0]['alias'];
} else {
$alias = $from[0]['table'];
}
$query->addSelect($this->getPlatformGroupConcat('fields', $query))->leftJoin($alias, $this->mapping['tables']['field_value'], 'f', "f.content_id = {$alias}.id AND f.contenttype='{$boltname}' AND f.name='{$field}'");
}
示例6: load
/**
* For relations, the load method adds an extra ->addSelect() and ->leftJoin() to the query that
* fetches the related records from the join table in the same query as the content fetch.
*
* IDs are returned comma-separated which the ->hydrate() method can then turn into pointers
* to the related entities.
*
* @param QueryBuilder $query
* @param ClassMetadata $metadata
*/
public function load(QueryBuilder $query, ClassMetadata $metadata)
{
$field = $this->mapping['fieldname'];
$target = $this->mapping['target'];
$boltname = $metadata->getBoltName();
$from = $query->getQueryPart('from');
if (isset($from[0]['alias'])) {
$alias = $from[0]['alias'];
} else {
$alias = $from[0]['table'];
}
$query->addSelect($this->getPlatformGroupConcat("{$field}.to_id", $field, $query))->leftJoin($alias, $target, $field, "{$alias}.id = {$field}.from_id AND {$field}.from_contenttype='{$boltname}' AND {$field}.to_contenttype='{$field}'")->addGroupBy("{$alias}.id");
}
示例7: addAdditonalWhereConditions
/**
* Add the additional query conditions returned by the QueryRestrictionBuilder
* to the current query and return the original set of conditions so that they
* can be restored after the query has been built/executed.
*
* @return \Doctrine\DBAL\Query\Expression\CompositeExpression|mixed
*/
protected function addAdditonalWhereConditions()
{
$queryRestrictionBuilder = GeneralUtility::makeInstance(QueryRestrictionBuilder::class, $this->getQueriedTables(), $this->expr(), $this->getQueryContext());
$originalWhereConditions = $this->concreteQueryBuilder->getQueryPart('where');
if ($originalWhereConditions instanceof CompositeExpression) {
$originalWhereConditions = clone $originalWhereConditions;
}
$additionalQueryRestrictions = $queryRestrictionBuilder->getVisibilityConstraints();
if ($additionalQueryRestrictions->count() !== 0) {
// save the original query conditions so we can restore
// them after the query has been built.
$this->concreteQueryBuilder->andWhere($additionalQueryRestrictions);
}
return $originalWhereConditions;
}
示例8: load
/**
* @inheritdoc
*/
public function load(QueryBuilder $query, ClassMetadata $metadata)
{
$field = $this->mapping['fieldname'];
$boltname = $metadata->getBoltName();
if ($this->mapping['data']['has_sortorder']) {
$order = "{$field}.sortorder";
} else {
$order = "{$field}.id";
}
$from = $query->getQueryPart('from');
if (isset($from[0]['alias'])) {
$alias = $from[0]['alias'];
} else {
$alias = $from[0]['table'];
}
$query->addSelect($this->getPlatformGroupConcat("{$field}.slug", $order, $field, $query))->leftJoin($alias, 'bolt_taxonomy', $field, "{$alias}.id = {$field}.content_id AND {$field}.contenttype='{$boltname}' AND {$field}.taxonomytype='{$field}'")->addGroupBy("{$alias}.id");
}
示例9: preprocess
/**
* Preprocess and execute SELECT query.
*
* @param \Doctrine\DBAL\Query\QueryBuilder $qb
*
* @throws \Lokhman\Silex\ARM\Exception\RepositoryException
* @return \Doctrine\DBAL\Driver\Statement
*/
private function preprocess(QueryBuilder $qb)
{
// for each FROM part in QueryBuilder
foreach ($qb->getQueryPart('from') as $part) {
$table = $table = $this->prefix . $part['table'];
if (!isset($this->app['arm'][$table])) {
self::raise('No repository registered for "' . $table . '".');
}
$tables[$part['alias']] = $this->app['arm'][$table];
}
// for each JOIN part in QueryBuilder
foreach ($qb->getQueryPart('join') as $part) {
$table = $this->prefix . $part[0]['joinTable'];
if (!isset($this->app['arm'][$table])) {
self::raise('No repository registered for "' . $table . '".');
}
$tables[$part[0]['joinAlias']] = $this->app['arm'][$table];
}
// re-define select columns
$qb->select($this->formatSelect($qb, $tables));
// execute pre-formatted SELECT query ( $qb->execute() )
return $this->db->executeQuery($this->formatQuery($qb, $tables), $qb->getParameters(), $qb->getParameterTypes());
}
示例10: addTotalCountSelect
/**
* Modifies the passed DBAL query builder object to calculate
* the total count.
*
* @param QueryBuilder $builder
* @return $this
*/
private function addTotalCountSelect(QueryBuilder $builder)
{
$select = $builder->getQueryPart('select');
$select[0] = ' SQL_CALC_FOUND_ROWS ' . $select[0];
$builder->select($select);
return $this;
}
示例11: getQueryPartDelegatesToConcreteQueryBuilder
/**
* @test
*/
public function getQueryPartDelegatesToConcreteQueryBuilder()
{
$this->concreteQueryBuilder->getQueryPart('from')->shouldBeCalled()->willReturn('aTable');
$this->subject->getQueryPart('from');
}
示例12: applySearchQueryRelationship
/**
* @param QueryBuilder $q
* @param array $tables $tables[0] should be primary table
* @param bool $innerJoinTables
* @param null $whereExpression
* @param null $having
*/
protected function applySearchQueryRelationship(QueryBuilder $q, array $tables, $innerJoinTables, $whereExpression = null, $having = null)
{
$primaryTable = $tables[0];
unset($tables[0]);
$joinType = $innerJoinTables ? 'join' : 'leftJoin';
$this->useDistinctCount = true;
$joins = $q->getQueryPart('join');
if (!array_key_exists($primaryTable['alias'], $joins)) {
$q->{$joinType}($primaryTable['from_alias'], MAUTIC_TABLE_PREFIX . $primaryTable['table'], $primaryTable['alias'], $primaryTable['condition']);
foreach ($tables as $table) {
$q->{$joinType}($table['from_alias'], MAUTIC_TABLE_PREFIX . $table['table'], $table['alias'], $table['condition']);
}
if ($whereExpression) {
$q->andWhere($whereExpression);
}
if ($having) {
$q->andHaving($having);
}
$q->groupBy('l.id');
}
}
示例13: getQueryPart
/**
* Gets a query part by its name.
*
* @param string $queryPartName
*
* @return mixed
*/
public function getQueryPart($queryPartName)
{
return $this->queryBuilder->getQueryPart($queryPartName);
}
示例14: hasQueryBuilderJoins
private function hasQueryBuilderJoins(QueryBuilder $queryBuilder)
{
$joins = $queryBuilder->getQueryPart('join');
return !empty($joins);
}
示例15: setLastInsertId
/**
* @TODO Temporary workaround for PostgreSQL databases that don't use a sequence.
*
* @param QueryBuilder $query
*/
private function setLastInsertId(QueryBuilder $query)
{
$seq = null;
if ($query->getConnection()->getDatabasePlatform()->getName() === 'postgresql') {
$sequences = $query->getConnection()->getSchemaManager()->listSequences();
$desiredSeq = $query->getQueryPart('from')['table'] . '_id_seq';
foreach ($sequences as $sequence) {
if ($desiredSeq === $sequence->getName()) {
$seq = $desiredSeq;
break;
}
}
}
$this->lastInsertId = $query->getConnection()->lastInsertId($seq);
}