Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

DDC-1069 - Fix error in docblocks of query builder

  • Loading branch information...
commit 61e371cbdc8c4ec4465ee12c4357de1b61240c89 1 parent b44ff9b
@beberlei beberlei authored
Showing with 59 additions and 59 deletions.
  1. +59 −59 lib/Doctrine/ORM/QueryBuilder.php
View
118 lib/Doctrine/ORM/QueryBuilder.php
@@ -74,7 +74,7 @@ class QueryBuilder
* @var string The complete DQL string for this query.
*/
private $_dql;
-
+
/**
* @var array The query parameters.
*/
@@ -84,12 +84,12 @@ class QueryBuilder
* @var array The parameter type map of this query.
*/
private $_paramTypes = array();
-
+
/**
* @var integer The index of the first result to retrieve.
*/
private $_firstResult = null;
-
+
/**
* @var integer The maximum number of results to retrieve.
*/
@@ -97,7 +97,7 @@ class QueryBuilder
/**
* Initializes a new <tt>QueryBuilder</tt> that uses the given <tt>EntityManager</tt>.
- *
+ *
* @param EntityManager $em The EntityManager to use.
*/
public function __construct(EntityManager $em)
@@ -217,7 +217,7 @@ public function getQuery()
->setFirstResult($this->_firstResult)
->setMaxResults($this->_maxResults);
}
-
+
/**
* Gets the FIRST root alias of the query. This is the first entity alias involved
* in the construction of the query.
@@ -256,7 +256,7 @@ public function getRootAlias()
public function getRootAliases()
{
$aliases = array();
-
+
foreach ($this->_dqlParts['from'] as &$fromClause) {
if (is_string($fromClause)) {
$spacePos = strrpos($fromClause, ' ');
@@ -265,10 +265,10 @@ public function getRootAliases()
$fromClause = new Query\Expr\From($from, $alias);
}
-
+
$aliases[] = $fromClause->getAlias();
}
-
+
return $aliases;
}
@@ -289,7 +289,7 @@ public function getRootAliases()
public function getRootEntities()
{
$entities = array();
-
+
foreach ($this->_dqlParts['from'] as &$fromClause) {
if (is_string($fromClause)) {
$spacePos = strrpos($fromClause, ' ');
@@ -298,10 +298,10 @@ public function getRootEntities()
$fromClause = new Query\Expr\From($from, $alias);
}
-
+
$entities[] = $fromClause->getFrom();
}
-
+
return $entities;
}
@@ -313,7 +313,7 @@ public function getRootEntities()
* ->select('u')
* ->from('User', 'u')
* ->where('u.id = :user_id')
- * ->setParameter(':user_id', 1);
+ * ->setParameter('user_id', 1);
* </code>
*
* @param string|integer $key The parameter position or name.
@@ -324,17 +324,17 @@ public function getRootEntities()
public function setParameter($key, $value, $type = null)
{
$key = trim($key, ':');
-
+
if ($type === null) {
$type = Query\ParameterTypeInferer::inferType($value);
}
-
+
$this->_paramTypes[$key] = $type;
$this->_params[$key] = $value;
-
+
return $this;
}
-
+
/**
* Sets a collection of query parameters for the query being constructed.
*
@@ -344,8 +344,8 @@ public function setParameter($key, $value, $type = null)
* ->from('User', 'u')
* ->where('u.id = :user_id1 OR u.id = :user_id2')
* ->setParameters(array(
- * ':user_id1' => 1,
- * ':user_id2' => 2
+ * 'user_id1' => 1,
+ * 'user_id2' => 2
* ));
* </code>
*
@@ -376,7 +376,7 @@ public function getParameters()
/**
* Gets a (previously set) query parameter of the query being constructed.
- *
+ *
* @param mixed $key The key (index or name) of the bound parameter.
* @return mixed The value of the bound parameter.
*/
@@ -400,17 +400,17 @@ public function setFirstResult($firstResult)
/**
* Gets the position of the first result the query object was set to retrieve (the "offset").
* Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
- *
+ *
* @return integer The position of the first result.
*/
public function getFirstResult()
{
return $this->_firstResult;
}
-
+
/**
* Sets the maximum number of results to retrieve (the "limit").
- *
+ *
* @param integer $maxResults The maximum number of results to retrieve.
* @return QueryBuilder This QueryBuilder instance.
*/
@@ -419,11 +419,11 @@ public function setMaxResults($maxResults)
$this->_maxResults = $maxResults;
return $this;
}
-
+
/**
* Gets the maximum number of results the query object was set to retrieve (the "limit").
* Returns NULL if {@link setMaxResults} was not applied to this query builder.
- *
+ *
* @return integer Maximum number of results.
*/
public function getMaxResults()
@@ -437,15 +437,15 @@ public function getMaxResults()
* The available parts are: 'select', 'from', 'join', 'set', 'where',
* 'groupBy', 'having' and 'orderBy'.
*
- * @param string $dqlPartName
- * @param string $dqlPart
- * @param string $append
+ * @param string $dqlPartName
+ * @param string $dqlPart
+ * @param string $append
* @return QueryBuilder This QueryBuilder instance.
*/
public function add($dqlPartName, $dqlPart, $append = false)
{
$isMultiple = is_array($this->_dqlParts[$dqlPartName]);
-
+
// This is introduced for backwards compatibility reasons.
// TODO: Remove for 3.0
if ($dqlPartName == 'join') {
@@ -459,11 +459,11 @@ public function add($dqlPartName, $dqlPart, $append = false)
}
$dqlPart = $newDqlPart;
}
-
+
if ($append && $isMultiple) {
if (is_array($dqlPart)) {
$key = key($dqlPart);
-
+
$this->_dqlParts[$dqlPartName][$key][] = $dqlPart[$key];
} else {
$this->_dqlParts[$dqlPartName][] = $dqlPart;
@@ -494,11 +494,11 @@ public function add($dqlPartName, $dqlPart, $append = false)
public function select($select = null)
{
$this->_type = self::SELECT;
-
+
if (empty($select)) {
return $this;
}
-
+
$selects = is_array($select) ? $select : func_get_args();
return $this->add('select', new Expr\Select($selects), false);
@@ -521,11 +521,11 @@ public function select($select = null)
public function addSelect($select = null)
{
$this->_type = self::SELECT;
-
+
if (empty($select)) {
return $this;
}
-
+
$selects = is_array($select) ? $select : func_get_args();
return $this->add('select', new Expr\Select($selects), true);
@@ -539,7 +539,7 @@ public function addSelect($select = null)
* $qb = $em->createQueryBuilder()
* ->delete('User', 'u')
* ->where('u.id = :user_id');
- * ->setParameter(':user_id', 1);
+ * ->setParameter('user_id', 1);
* </code>
*
* @param string $delete The class/type whose instances are subject to the deletion.
@@ -631,7 +631,7 @@ public function join($join, $alias, $conditionType = null, $condition = null, $i
/**
* Creates and adds a join over an entity association to the query.
- *
+ *
* The entities in the joined association will be fetched as part of the query
* result if the alias used for the joined association is placed in the select
* expressions.
@@ -655,7 +655,7 @@ public function innerJoin($join, $alias, $conditionType = null, $condition = nul
if (!in_array($rootAlias, $this->getRootAliases())) {
$rootAlias = $this->getRootAlias();
}
-
+
return $this->add('join', array(
$rootAlias => new Expr\Join(Expr\Join::INNER_JOIN, $join, $alias, $conditionType, $condition, $indexBy)
), true);
@@ -688,7 +688,7 @@ public function leftJoin($join, $alias, $conditionType = null, $condition = null
if (!in_array($rootAlias, $this->getRootAliases())) {
$rootAlias = $this->getRootAlias();
}
-
+
return $this->add('join', array(
$rootAlias => new Expr\Join(Expr\Join::LEFT_JOIN, $join, $alias, $conditionType, $condition, $indexBy)
), true);
@@ -743,7 +743,7 @@ public function where($predicates)
if ( ! (func_num_args() == 1 && $predicates instanceof Expr\Composite)) {
$predicates = new Expr\Andx(func_get_args());
}
-
+
return $this->add('where', $predicates);
}
@@ -767,14 +767,14 @@ public function andWhere($where)
{
$where = $this->getDQLPart('where');
$args = func_get_args();
-
+
if ($where instanceof Expr\Andx) {
$where->addMultiple($args);
- } else {
+ } else {
array_unshift($args, $where);
$where = new Expr\Andx($args);
}
-
+
return $this->add('where', $where, true);
}
@@ -798,14 +798,14 @@ public function orWhere($where)
{
$where = $this->getDqlPart('where');
$args = func_get_args();
-
+
if ($where instanceof Expr\Orx) {
$where->addMultiple($args);
- } else {
+ } else {
array_unshift($args, $where);
$where = new Expr\Orx($args);
}
-
+
return $this->add('where', $where, true);
}
@@ -860,7 +860,7 @@ public function having($having)
if ( ! (func_num_args() == 1 && ($having instanceof Expr\Andx || $having instanceof Expr\Orx))) {
$having = new Expr\Andx(func_get_args());
}
-
+
return $this->add('having', $having);
}
@@ -875,14 +875,14 @@ public function andHaving($having)
{
$having = $this->getDqlPart('having');
$args = func_get_args();
-
+
if ($having instanceof Expr\Andx) {
$having->addMultiple($args);
- } else {
+ } else {
array_unshift($args, $having);
$having = new Expr\Andx($args);
}
-
+
return $this->add('having', $having);
}
@@ -897,10 +897,10 @@ public function orHaving($having)
{
$having = $this->getDqlPart('having');
$args = func_get_args();
-
+
if ($having instanceof Expr\Orx) {
$having->addMultiple($args);
- } else {
+ } else {
array_unshift($args, $having);
$having = new Expr\Orx($args);
}
@@ -977,15 +977,15 @@ private function _getDQLForUpdate()
private function _getDQLForSelect()
{
$dql = 'SELECT' . $this->_getReducedDQLQueryPart('select', array('pre' => ' ', 'separator' => ', '));
-
+
$fromParts = $this->getDQLPart('from');
$joinParts = $this->getDQLPart('join');
$fromClauses = array();
-
+
// Loop through all FROM clauses
if ( ! empty($fromParts)) {
$dql .= ' FROM ';
-
+
foreach ($fromParts as $from) {
$fromClause = (string) $from;
@@ -998,24 +998,24 @@ private function _getDQLForSelect()
$fromClauses[] = $fromClause;
}
}
-
- $dql .= implode(', ', $fromClauses)
+
+ $dql .= implode(', ', $fromClauses)
. $this->_getReducedDQLQueryPart('where', array('pre' => ' WHERE '))
. $this->_getReducedDQLQueryPart('groupBy', array('pre' => ' GROUP BY ', 'separator' => ', '))
. $this->_getReducedDQLQueryPart('having', array('pre' => ' HAVING '))
. $this->_getReducedDQLQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', '));
-
+
return $dql;
}
private function _getReducedDQLQueryPart($queryPartName, $options = array())
{
$queryPart = $this->getDQLPart($queryPartName);
-
+
if (empty($queryPart)) {
return (isset($options['empty']) ? $options['empty'] : '');
}
-
+
return (isset($options['pre']) ? $options['pre'] : '')
. (is_array($queryPart) ? implode($options['separator'], $queryPart) : $queryPart)
. (isset($options['post']) ? $options['post'] : '');
Please sign in to comment.
Something went wrong with that request. Please try again.