本文整理汇总了PHP中Doctrine\ORM\QueryBuilder::getFirstResult方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::getFirstResult方法的具体用法?PHP QueryBuilder::getFirstResult怎么用?PHP QueryBuilder::getFirstResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::getFirstResult方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateDataSet_pagination
public function testCreateDataSet_pagination()
{
$request = $this->getBaseRequest();
$request->displayStart = 100;
$request->displayLength = 10;
$dataSet = $this->dataSource->createDataSet($request);
$this->assertEquals(100, $this->qb->getFirstResult());
$this->assertEquals(10, $this->qb->getMaxResults());
}
示例2: getData
/**
* It is possible to use query builder with additional columns.
* In this case, only item at index [0] is returned, because
* it should be an entity object.
* @return array
*/
public function getData()
{
$data = array();
// Paginator is better if the query uses ManyToMany associations
$result = $this->qb->getMaxResults() !== NULL || $this->qb->getFirstResult() !== NULL ? new Paginator($this->getQuery()) : $this->qb->getQuery()->getResult();
foreach ($result as $item) {
// Return only entity itself
$data[] = is_array($item) ? $item[0] : $item;
}
return $data;
}
示例3: getData
/**
* It is possible to use query builder with additional columns.
* In this case, only item at index [0] is returned, because
* it should be an entity object.
* @return array
*/
public function getData()
{
// Paginator is better if the query uses ManyToMany associations
$usePaginator = $this->qb->getMaxResults() !== NULL || $this->qb->getFirstResult() !== NULL;
$data = array();
if ($usePaginator) {
$paginator = new Paginator($this->getQuery());
// Convert paginator to the array
foreach ($paginator as $result) {
// Return only entity itself
$data[] = is_array($result) ? $result[0] : $result;
}
} else {
foreach ($this->qb->getQuery()->getResult() as $result) {
// Return only entity itself
$data[] = is_array($result) ? $result[0] : $result;
}
}
return $data;
}
示例4: getFirstResult
/**
* {@inheritdoc}
*/
public function getFirstResult()
{
return $this->queryBuilder->getFirstResult();
}
示例5: getCount
/**
* @param type $select string podawany do $qb->select np $qb->select('count(*)'[, ...])
* Nalezy podać tylko jeden parametr!!!!!!!!!!!!!!!!
*/
public function getCount()
{
$offset = $this->qb->getFirstResult();
$this->qb->setFirstResult(null);
$tmp = call_user_func_array(array($this->qb, 'select'), func_get_args());
$return = $tmp->getQuery()->getSingleScalarResult();
$this->qb->setFirstResult($offset);
return $return;
}