本文整理汇总了PHP中Doctrine\ORM\QueryBuilder::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::getQuery方法的具体用法?PHP QueryBuilder::getQuery怎么用?PHP QueryBuilder::getQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::getQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: searchOne
/**
* @param ChannelConditionInterface $condition
* @return ChannelInterface
*/
public function searchOne(ChannelConditionInterface $condition)
{
$this->qb = $this->em->createQueryBuilder();
$this->qb->select('ch')->from('CoreBundle:Channel', 'ch');
$this->initQueryBuilder($condition);
return $this->qb->getQuery()->getOneOrNullResult();
}
示例2: getData
/**
* Get the data
* @return array
*/
public function getData()
{
/**
* Paginator is better if the query uses ManyToMany associations
*/
return $this->data ?: $this->data_source->getQuery()->getResult();
}
示例3: getData
/**
* Get the data
* @return array
*/
public function getData()
{
/**
* Paginator is better if the query uses ManyToMany associations
*/
return $this->data ?: $this->data_source->getQuery()->getResult(Doctrine\ORM\Query::HYDRATE_ARRAY);
}
示例4: getEntities
/**
* {@inheritdoc}
*/
public function getEntities()
{
$query = $this->queryBuilder->getQuery();
foreach ($this->hints as $name => $value) {
$query->setHint($name, $value);
}
return $query->execute();
}
示例5: search
/**
* @param CompanyConditionInterface $condition
* @return Company[]
*/
public function search(CompanyConditionInterface $condition)
{
$this->qb = $this->em->createQueryBuilder();
$this->qb->select('co')->from('CoreBundle:Company', 'co');
$this->initQueryBuilder($condition);
$this->preparePagination($this->qb, $condition);
return $this->qb->getQuery()->getResult();
}
示例6: convert
/**
* Convert an array of ID's to Doctrine entities / arrays
*
* @param array $data
* @return array
*/
public function convert($data)
{
if (empty($data)) {
return array();
}
$this->qb->andWhere($this->qb->expr()->in($this->searchfield, $data));
return $this->qb->getQuery()->getResult();
}
示例7: getResults
/**
* @return ResultRecordInterface[]
*/
public function getResults()
{
$results = $this->qb->getQuery()->execute();
$rows = [];
foreach ($results as $result) {
$rows[] = new ResultRecord($result);
}
return $rows;
}
示例8: getEntities
/**
* {@inheritDoc}
*
* This function overwrites the original function to add the "automaticSorting" functionnality
*/
public function getEntities()
{
$entities = $this->queryBuilder->getQuery()->execute();
// If automaticSorting is On
if ($this->automaticSorting) {
// Sort the entities
$entities = $this->treeEntityOrderer->sortEntities($entities);
}
return $entities;
}
示例9: getItems
public function getItems()
{
$this->qb->setMaxResults($this->getLimit());
$this->qb->setFirstResult($this->getOffset());
list($sortColumn, $sortType) = $this->getSorting();
if ($sortColumn) {
$this->qb->orderBy($this->qb->getRootAlias() . "." . $sortColumn, $sortType);
}
return $this->qb->getQuery()->getResult();
}
示例10: processQuery
/**
* Returns the Query Builder or the results depending on the repository parameters
*
* @param \Doctrine\ORM\QueryBuilder $queryBuilder
* @param bool $singleResult
*
* @return mixed
*/
protected function processQuery($queryBuilder, $singleResult = false)
{
if ($this->returnQueryBuilder) {
return $queryBuilder;
}
if ($singleResult) {
return $queryBuilder->getQuery()->getSingleResult();
}
return $queryBuilder->getQuery()->getResult();
}
示例11: getResults
/**
* @return ResultRecordInterface[]
*/
public function getResults()
{
$query = $this->aclHelper->apply($this->qb->getQuery());
$results = $query->execute();
$rows = [];
foreach ($results as $result) {
$rows[] = new ResultRecord($result);
}
return $rows;
}
示例12: processOrderByForList
protected function processOrderByForList(QueryBuilder $qb, $orderBy)
{
$fieldName = is_array($orderBy) ? key($orderBy) : $orderBy;
$order = is_array($orderBy) ? $orderBy[$fieldName] : 'ASC';
if (in_array($fieldName, ['visits', 'visitsCount', 'visitCount'])) {
$qb->addSelect('COUNT(v) AS totalVisits')->leftJoin('s.visits', 'v')->groupBy('s')->orderBy('totalVisits', $order);
return array_column($qb->getQuery()->getResult(), 0);
} elseif (in_array($fieldName, ['originalUrl', 'shortCode', 'dateCreated'])) {
$qb->orderBy('s.' . $fieldName, $order);
}
return $qb->getQuery()->getResult();
}
示例13: loadEntities
protected function loadEntities()
{
if ($this->query) {
$items = $this->query->getQuery()->getResult();
} else {
$meta = $this->form->mapper->entityManager->getClassMetadata(get_class($this->parent->data));
if (!$meta->hasAssociation($this->name)) {
throw new Nette\InvalidStateException();
}
$class = $meta->associationMappings[$this->name]['targetEntity'];
$items = $this->getParent()->form->mapper->entityManager->getRepository($class)->findBy($this->criteria, $this->orderBy, $this->limit, $this->offset);
}
$this->setItems($items);
}
示例14: getData
public function getData(array $p_params, array $p_cols)
{
$this->_queryObject = $this->_repository->createQueryBuilder('e');
// search
if (!empty($p_params['search'])) {
$this->search($p_params['search'], $p_cols);
}
// sort
if (@count($p_params['sortCol'])) {
$this->sort($p_params, $p_cols);
}
// limit
$this->_queryObject->setFirstResult((int) $p_params['displayStart'])->setMaxResults((int) $p_params['displayLength']);
return $this->_queryObject->getQuery()->getResult();
}
示例15: getResults
/**
* @return ResultRecordInterface[]
*/
public function getResults()
{
$query = $this->qb->getQuery();
$this->setQueryHints($query);
$event = new OrmResultBefore($this->datagrid, $query);
$this->eventDispatcher->dispatch(OrmResultBefore::NAME, $event);
$results = $event->getQuery()->execute();
$rows = [];
foreach ($results as $result) {
$rows[] = new ResultRecord($result);
}
$event = new OrmResultAfter($this->datagrid, $rows);
$this->eventDispatcher->dispatch(OrmResultAfter::NAME, $event);
return $event->getRecords();
}