本文整理汇总了PHP中Doctrine\ORM\Query::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::execute方法的具体用法?PHP Query::execute怎么用?PHP Query::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Query
的用法示例。
在下文中一共展示了Query::execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: count
public function count()
{
if ($this->count === null) {
if ($this->countQuery) {
try {
$res = $this->countQuery->execute();
$this->count = $res[0]['c'];
} catch (NoResultException $e) {
$this->count = 0;
}
} else {
$this->count = parent::count();
}
}
return $this->count;
}
示例2: execute
/**
* Executes query and saving query SQL to list (if needed)
*
* @access public
* @param boolean $noResults returns no results, if TRUE
* @return array
* @since 1.0.0-alpha
* @version 1.0.0-alpha
*/
public function execute($noResults = FALSE)
{
if (!$noResults) {
static::$mResult = $this->oQuery->getResult();
} else {
static::$mResult = $this->oQuery->execute();
}
return static::$mResult;
}
示例3: getPostIds
/**
* @param DBALQueryBuilder|Query $queryBuilder
*
* @return int[]
*/
private function getPostIds($queryBuilder)
{
$ids = [];
if ($queryBuilder instanceof DBALQueryBuilder) {
foreach ($queryBuilder->execute()->fetchAll() as $post) {
$ids[] = (int) $post['id'];
}
} elseif ($queryBuilder instanceof Query) {
foreach ($queryBuilder->getResult() as $post) {
$ids[] = $post->getId();
}
}
return array_unique($ids);
}
示例4: _performQuery
/**
* _performQuery() - This method accepts a Doctrine\ORM\Query object and
* performs a query against the database with that object.
*
* @param Doctrine\ORM\Query $query
* @throws \Zend\Authentication\Adapter\Exception\RuntimeException - when a invalid select object is encoutered
* @return array
*/
protected function _performQuery(\Doctrine\ORM\Query $query)
{
try {
$resultIdentities = $query->execute();
} catch (Exception $e) {
/**
* @see \Zend\Authentication\Adapter\Exception\RuntimeException
*/
require_once 'Zend/Auth/Adapter/Exception.php';
throw new \Zend\Authentication\Adapter\Exception\RuntimeException('The supplied parameters to \\Doctrine\\ORM\\EntityManager failed to ' . 'produce a valid sql statement, please check entity and column names ' . 'for validity.');
}
return $resultIdentities;
}
示例5: fetch
public function fetch(Query $query, $mode = self::FETCH_ALL)
{
if ($mode == self::FETCH_ALL) {
if ($query->getMaxResults() !== null && $query->getHydrationMode() != self::HYDRATE_SINGLE_SCALAR) {
return (new Paginator($query))->getIterator()->getArrayCopy();
} else {
return $query->execute();
}
} else {
if ($mode == self::FETCH_ALL_PAGED) {
return new Paginator($query);
} else {
if ($mode == self::FETCH_ONE) {
$query->setMaxResults(1);
if ($query->getHydrationMode() != self::HYDRATE_SINGLE_SCALAR) {
return (new Paginator($query))->getIterator()->current();
} else {
return $query->getOneOrNullResult();
}
} else {
if ($mode == self::FETCH_ONE_UNIQUE) {
return $query->getOneOrNullResult();
}
}
}
}
}