Commit d10daf35 authored by jwage's avatar jwage

[2.0] Changing Expr static methods to be normal public methods (closes #2466)

parent dbce89d7
...@@ -40,13 +40,13 @@ class Expr ...@@ -40,13 +40,13 @@ class Expr
* *
* [php] * [php]
* // (u.type = ?1) AND (u.role = ?2) * // (u.type = ?1) AND (u.role = ?2)
* $q->where(Expr::andx('u.type = ?1', 'u.role = ?2')); * $q->where($q->expr()->andx('u.type = ?1', 'u.role = ?2'));
* *
* @param mixed $x Optional clause. Defaults = null, but requires * @param mixed $x Optional clause. Defaults = null, but requires
* at least one defined when converting to string. * at least one defined when converting to string.
* @return Expr\Andx * @return Expr\Andx
*/ */
public static function andx($x = null) public function andx($x = null)
{ {
return new Expr\Andx(func_get_args()); return new Expr\Andx(func_get_args());
} }
...@@ -57,13 +57,13 @@ class Expr ...@@ -57,13 +57,13 @@ class Expr
* *
* [php] * [php]
* // (u.type = ?1) OR (u.role = ?2) * // (u.type = ?1) OR (u.role = ?2)
* $q->where(Expr::orx('u.type = ?1', 'u.role = ?2')); * $q->where($q->expr()->orx('u.type = ?1', 'u.role = ?2'));
* *
* @param mixed $x Optional clause. Defaults = null, but requires * @param mixed $x Optional clause. Defaults = null, but requires
* at least one defined when converting to string. * at least one defined when converting to string.
* @return Expr\Orx * @return Expr\Orx
*/ */
public static function orx($x = null) public function orx($x = null)
{ {
return new Expr\Orx(func_get_args()); return new Expr\Orx(func_get_args());
} }
...@@ -74,13 +74,13 @@ class Expr ...@@ -74,13 +74,13 @@ class Expr
* *
* [php] * [php]
* // u.id, u.name, u.surname * // u.id, u.name, u.surname
* $q->select(Expr::select('u.id', 'u.name')->add('u.surname')); * $q->select($q->expr()->select('u.id', 'u.name')->add('u.surname'));
* *
* @param mixed $select Optional select. Defaults = null, but requires * @param mixed $select Optional select. Defaults = null, but requires
* at least one defined when converting to string. * at least one defined when converting to string.
* @return Expr\Select * @return Expr\Select
*/ */
public static function select($select = null) public function select($select = null)
{ {
return new Expr\Select(func_get_args()); return new Expr\Select(func_get_args());
} }
...@@ -90,13 +90,13 @@ class Expr ...@@ -90,13 +90,13 @@ class Expr
* *
* [php] * [php]
* // User u * // User u
* $q->from(Expr::from('User', 'u')); * $q->from($q->expr()->from('User', 'u'));
* *
* @param string $from Entity name. * @param string $from Entity name.
* @param string $alias Optional alias to be used by Entity. * @param string $alias Optional alias to be used by Entity.
* @return Expr\From * @return Expr\From
*/ */
public static function from($from, $alias = null) public function from($from, $alias = null)
{ {
return new Expr\From($from, $alias); return new Expr\From($from, $alias);
} }
...@@ -106,7 +106,7 @@ class Expr ...@@ -106,7 +106,7 @@ class Expr
* *
* [php] * [php]
* // LEFT JOIN u.Group g WITH g.name = 'admin' * // LEFT JOIN u.Group g WITH g.name = 'admin'
* Expr::leftJoin('u.Group', 'g', 'WITH', "g.name = 'admin'") * $q->expr()->leftJoin('u.Group', 'g', 'WITH', "g.name = 'admin'")
* *
* @param string $join Relation join. * @param string $join Relation join.
* @param string $alias Optional alias to be used by Relation. * @param string $alias Optional alias to be used by Relation.
...@@ -115,7 +115,7 @@ class Expr ...@@ -115,7 +115,7 @@ class Expr
* @param mixed $condition Optional condition to be appended. * @param mixed $condition Optional condition to be appended.
* @return Expr\Join * @return Expr\Join
*/ */
public static function leftJoin($join, $alias = null, $conditionType = null, $condition = null) public function leftJoin($join, $alias = null, $conditionType = null, $condition = null)
{ {
return new Expr\Join(Expr\Join::LEFT_JOIN, $join, $alias, $conditionType, $condition); return new Expr\Join(Expr\Join::LEFT_JOIN, $join, $alias, $conditionType, $condition);
} }
...@@ -125,7 +125,7 @@ class Expr ...@@ -125,7 +125,7 @@ class Expr
* *
* [php] * [php]
* // INNER JOIN u.Group g WITH g.name = 'admin' * // INNER JOIN u.Group g WITH g.name = 'admin'
* Expr::innerJoin('u.Group', 'g', 'WITH', "g.name = 'admin'") * $q->expr()->innerJoin('u.Group', 'g', 'WITH', "g.name = 'admin'")
* *
* @param string $join Relation join. * @param string $join Relation join.
* @param string $alias Optional alias to be used by Relation. * @param string $alias Optional alias to be used by Relation.
...@@ -134,7 +134,7 @@ class Expr ...@@ -134,7 +134,7 @@ class Expr
* @param mixed $condition Optional condition to be appended. * @param mixed $condition Optional condition to be appended.
* @return Expr\Join * @return Expr\Join
*/ */
public static function innerJoin($join, $alias = null, $conditionType = null, $condition = null) public function innerJoin($join, $alias = null, $conditionType = null, $condition = null)
{ {
return new Expr\Join(Expr\Join::INNER_JOIN, $join, $alias, $conditionType, $condition); return new Expr\Join(Expr\Join::INNER_JOIN, $join, $alias, $conditionType, $condition);
} }
...@@ -144,13 +144,13 @@ class Expr ...@@ -144,13 +144,13 @@ class Expr
* Each argument is separated by a ",". Example: * Each argument is separated by a ",". Example:
* *
* [php] * [php]
* $q->orderBy(Expr::orderBy('u.surname', 'ASC')->add('u.name', 'ASC')); * $q->orderBy($q->expr()->orderBy('u.surname', 'ASC')->add('u.name', 'ASC'));
* *
* @param string $sort Optional item sort. * @param string $sort Optional item sort.
* @param string $order Optional order to be applied in item. * @param string $order Optional order to be applied in item.
* @return Expr\OrderBy * @return Expr\OrderBy
*/ */
public static function orderBy($sort = null, $order = null) public function orderBy($sort = null, $order = null)
{ {
return new Expr\OrderBy($sort, $order); return new Expr\OrderBy($sort, $order);
} }
...@@ -161,13 +161,13 @@ class Expr ...@@ -161,13 +161,13 @@ class Expr
* *
* [php] * [php]
* // u.id, u.name * // u.id, u.name
* $q->select(Expr::groupBy('u.id', 'u.name')); * $q->select($q->expr()->groupBy('u.id', 'u.name'));
* *
* @param mixed $groupBy Optional group by. Defaults = null, but requires * @param mixed $groupBy Optional group by. Defaults = null, but requires
* at least one defined when converting to string. * at least one defined when converting to string.
* @return Expr\Select * @return Expr\Select
*/ */
public static function groupBy($groupBy = null) public function groupBy($groupBy = null)
{ {
return new Expr\GroupBy(func_get_args()); return new Expr\GroupBy(func_get_args());
} }
...@@ -179,13 +179,13 @@ class Expr ...@@ -179,13 +179,13 @@ class Expr
* *
* [php] * [php]
* // u.id = ?1 * // u.id = ?1
* $q->where(Expr::eq('u.id', '?1')); * $q->where($q->expr()->eq('u.id', '?1'));
* *
* @param mixed $x Left expression * @param mixed $x Left expression
* @param mixed $y Right expression * @param mixed $y Right expression
* @return Expr\Comparison * @return Expr\Comparison
*/ */
public static function eq($x, $y) public function eq($x, $y)
{ {
return new Expr\Comparison($x, Expr\Comparison::EQ, $y); return new Expr\Comparison($x, Expr\Comparison::EQ, $y);
} }
...@@ -197,13 +197,13 @@ class Expr ...@@ -197,13 +197,13 @@ class Expr
* *
* [php] * [php]
* // u.id <> ?1 * // u.id <> ?1
* $q->where(Expr::neq('u.id', '?1')); * $q->where($q->expr()->neq('u.id', '?1'));
* *
* @param mixed $x Left expression * @param mixed $x Left expression
* @param mixed $y Right expression * @param mixed $y Right expression
* @return Expr\Comparison * @return Expr\Comparison
*/ */
public static function neq($x, $y) public function neq($x, $y)
{ {
return new Expr\Comparison($x, Expr\Comparison::NEQ, $y); return new Expr\Comparison($x, Expr\Comparison::NEQ, $y);
} }
...@@ -215,13 +215,13 @@ class Expr ...@@ -215,13 +215,13 @@ class Expr
* *
* [php] * [php]
* // u.id < ?1 * // u.id < ?1
* $q->where(Expr::lt('u.id', '?1')); * $q->where($q->expr()->lt('u.id', '?1'));
* *
* @param mixed $x Left expression * @param mixed $x Left expression
* @param mixed $y Right expression * @param mixed $y Right expression
* @return Expr\Comparison * @return Expr\Comparison
*/ */
public static function lt($x, $y) public function lt($x, $y)
{ {
return new Expr\Comparison($x, Expr\Comparison::LT, $y); return new Expr\Comparison($x, Expr\Comparison::LT, $y);
} }
...@@ -233,13 +233,13 @@ class Expr ...@@ -233,13 +233,13 @@ class Expr
* *
* [php] * [php]
* // u.id <= ?1 * // u.id <= ?1
* $q->where(Expr::lte('u.id', '?1')); * $q->where($q->expr()->lte('u.id', '?1'));
* *
* @param mixed $x Left expression * @param mixed $x Left expression
* @param mixed $y Right expression * @param mixed $y Right expression
* @return Expr\Comparison * @return Expr\Comparison
*/ */
public static function lte($x, $y) public function lte($x, $y)
{ {
return new Expr\Comparison($x, Expr\Comparison::LTE, $y); return new Expr\Comparison($x, Expr\Comparison::LTE, $y);
} }
...@@ -251,13 +251,13 @@ class Expr ...@@ -251,13 +251,13 @@ class Expr
* *
* [php] * [php]
* // u.id > ?1 * // u.id > ?1
* $q->where(Expr::gt('u.id', '?1')); * $q->where($q->expr()->gt('u.id', '?1'));
* *
* @param mixed $x Left expression * @param mixed $x Left expression
* @param mixed $y Right expression * @param mixed $y Right expression
* @return Expr\Comparison * @return Expr\Comparison
*/ */
public static function gt($x, $y) public function gt($x, $y)
{ {
return new Expr\Comparison($x, Expr\Comparison::GT, $y); return new Expr\Comparison($x, Expr\Comparison::GT, $y);
} }
...@@ -269,13 +269,13 @@ class Expr ...@@ -269,13 +269,13 @@ class Expr
* *
* [php] * [php]
* // u.id >= ?1 * // u.id >= ?1
* $q->where(Expr::gte('u.id', '?1')); * $q->where($q->expr()->gte('u.id', '?1'));
* *
* @param mixed $x Left expression * @param mixed $x Left expression
* @param mixed $y Right expression * @param mixed $y Right expression
* @return Expr\Comparison * @return Expr\Comparison
*/ */
public static function gte($x, $y) public function gte($x, $y)
{ {
return new Expr\Comparison($x, Expr\Comparison::GTE, $y); return new Expr\Comparison($x, Expr\Comparison::GTE, $y);
} }
...@@ -286,7 +286,7 @@ class Expr ...@@ -286,7 +286,7 @@ class Expr
* @param mixed $x Argument to be used in AVG() function. * @param mixed $x Argument to be used in AVG() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function avg($x) public function avg($x)
{ {
return new Expr\Func('AVG', array($x)); return new Expr\Func('AVG', array($x));
} }
...@@ -297,7 +297,7 @@ class Expr ...@@ -297,7 +297,7 @@ class Expr
* @param mixed $x Argument to be used in MAX() function. * @param mixed $x Argument to be used in MAX() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function max($x) public function max($x)
{ {
return new Expr\Func('MAX', array($x)); return new Expr\Func('MAX', array($x));
} }
...@@ -308,7 +308,7 @@ class Expr ...@@ -308,7 +308,7 @@ class Expr
* @param mixed $x Argument to be used in MIN() function. * @param mixed $x Argument to be used in MIN() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function min($x) public function min($x)
{ {
return new Expr\Func('MIN', array($x)); return new Expr\Func('MIN', array($x));
} }
...@@ -319,7 +319,7 @@ class Expr ...@@ -319,7 +319,7 @@ class Expr
* @param mixed $x Argument to be used in COUNT() function. * @param mixed $x Argument to be used in COUNT() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function count($x) public function count($x)
{ {
return new Expr\Func('COUNT', array($x)); return new Expr\Func('COUNT', array($x));
} }
...@@ -330,7 +330,7 @@ class Expr ...@@ -330,7 +330,7 @@ class Expr
* @param mixed $x Argument to be used in COUNT(DISTINCT) function. * @param mixed $x Argument to be used in COUNT(DISTINCT) function.
* @return string * @return string
*/ */
public static function countDistinct($x) public function countDistinct($x)
{ {
return 'COUNT(DISTINCT ' . implode(', ', func_get_args()) . ')'; return 'COUNT(DISTINCT ' . implode(', ', func_get_args()) . ')';
} }
...@@ -341,7 +341,7 @@ class Expr ...@@ -341,7 +341,7 @@ class Expr
* @param mixed $subquery DQL Subquery to be used in EXISTS() function. * @param mixed $subquery DQL Subquery to be used in EXISTS() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function exists($subquery) public function exists($subquery)
{ {
return new Expr\Func('EXISTS', array($subquery)); return new Expr\Func('EXISTS', array($subquery));
} }
...@@ -352,7 +352,7 @@ class Expr ...@@ -352,7 +352,7 @@ class Expr
* @param mixed $subquery DQL Subquery to be used in ALL() function. * @param mixed $subquery DQL Subquery to be used in ALL() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function all($subquery) public function all($subquery)
{ {
return new Expr\Func('ALL', array($subquery)); return new Expr\Func('ALL', array($subquery));
} }
...@@ -363,7 +363,7 @@ class Expr ...@@ -363,7 +363,7 @@ class Expr
* @param mixed $subquery DQL Subquery to be used in SOME() function. * @param mixed $subquery DQL Subquery to be used in SOME() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function some($subquery) public function some($subquery)
{ {
return new Expr\Func('SOME', array($subquery)); return new Expr\Func('SOME', array($subquery));
} }
...@@ -374,7 +374,7 @@ class Expr ...@@ -374,7 +374,7 @@ class Expr
* @param mixed $subquery DQL Subquery to be used in ANY() function. * @param mixed $subquery DQL Subquery to be used in ANY() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function any($subquery) public function any($subquery)
{ {
return new Expr\Func('ANY', array($subquery)); return new Expr\Func('ANY', array($subquery));
} }
...@@ -385,7 +385,7 @@ class Expr ...@@ -385,7 +385,7 @@ class Expr
* @param mixed $restriction Restriction to be used in NOT() function. * @param mixed $restriction Restriction to be used in NOT() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function not($restriction) public function not($restriction)
{ {
return new Expr\Func('NOT', array($restriction)); return new Expr\Func('NOT', array($restriction));
} }
...@@ -396,7 +396,7 @@ class Expr ...@@ -396,7 +396,7 @@ class Expr
* @param mixed $x Argument to be used in ABS() function. * @param mixed $x Argument to be used in ABS() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function abs($x) public function abs($x)
{ {
return new Expr\Func('ABS', array($x)); return new Expr\Func('ABS', array($x));
} }
...@@ -408,13 +408,13 @@ class Expr ...@@ -408,13 +408,13 @@ class Expr
* *
* [php] * [php]
* // u.salary * u.percentAnualSalaryIncrease * // u.salary * u.percentAnualSalaryIncrease
* Expr::prod('u.salary', 'u.percentAnualSalaryIncrease') * $q->expr()->prod('u.salary', 'u.percentAnualSalaryIncrease')
* *
* @param mixed $x Left expression * @param mixed $x Left expression
* @param mixed $y Right expression * @param mixed $y Right expression
* @return Expr\Math * @return Expr\Math
*/ */
public static function prod($x, $y) public function prod($x, $y)
{ {
return new Expr\Math($x, '*', $y); return new Expr\Math($x, '*', $y);
} }
...@@ -426,13 +426,13 @@ class Expr ...@@ -426,13 +426,13 @@ class Expr
* *
* [php] * [php]
* // u.monthlySubscriptionCount - 1 * // u.monthlySubscriptionCount - 1
* Expr::diff('u.monthlySubscriptionCount', '1') * $q->expr()->diff('u.monthlySubscriptionCount', '1')
* *
* @param mixed $x Left expression * @param mixed $x Left expression
* @param mixed $y Right expression * @param mixed $y Right expression
* @return Expr\Math * @return Expr\Math
*/ */
public static function diff($x, $y) public function diff($x, $y)
{ {
return new Expr\Math($x, '-', $y); return new Expr\Math($x, '-', $y);
} }
...@@ -444,13 +444,13 @@ class Expr ...@@ -444,13 +444,13 @@ class Expr
* *
* [php] * [php]
* // u.numChildren + 1 * // u.numChildren + 1
* Expr::diff('u.numChildren', '1') * $q->expr()->diff('u.numChildren', '1')
* *
* @param mixed $x Left expression * @param mixed $x Left expression
* @param mixed $y Right expression * @param mixed $y Right expression
* @return Expr\Math * @return Expr\Math
*/ */
public static function sum($x, $y) public function sum($x, $y)
{ {
return new Expr\Math($x, '+', $y); return new Expr\Math($x, '+', $y);
} }
...@@ -462,13 +462,13 @@ class Expr ...@@ -462,13 +462,13 @@ class Expr
* *
* [php] * [php]
* // u.total - u.period * // u.total - u.period
* Expr::diff('u.total', 'u.period') * $q->expr()->diff('u.total', 'u.period')
* *
* @param mixed $x Left expression * @param mixed $x Left expression
* @param mixed $y Right expression * @param mixed $y Right expression
* @return Expr\Math * @return Expr\Math
*/ */
public static function quot($x, $y) public function quot($x, $y)
{ {
return new Expr\Math($x, '/', $y); return new Expr\Math($x, '/', $y);
} }
...@@ -479,7 +479,7 @@ class Expr ...@@ -479,7 +479,7 @@ class Expr
* @param mixed $x Argument to be used in SQRT() function. * @param mixed $x Argument to be used in SQRT() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function sqrt($x) public function sqrt($x)
{ {
return new Expr\Func('SQRT', array($x)); return new Expr\Func('SQRT', array($x));
} }
...@@ -491,7 +491,7 @@ class Expr ...@@ -491,7 +491,7 @@ class Expr
* @param mixed $y Argument to be used in IN() function. * @param mixed $y Argument to be used in IN() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function in($x, $y) public function in($x, $y)
{ {
return new Expr\Func($x . ' IN', (array) $y); return new Expr\Func($x . ' IN', (array) $y);
} }
...@@ -503,7 +503,7 @@ class Expr ...@@ -503,7 +503,7 @@ class Expr
* @param mixed $y Argument to be used in NOT IN() function. * @param mixed $y Argument to be used in NOT IN() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function notIn($x, $y) public function notIn($x, $y)
{ {
return new Expr\Func($x . ' NOT IN', (array) $y); return new Expr\Func($x . ' NOT IN', (array) $y);
} }
...@@ -515,7 +515,7 @@ class Expr ...@@ -515,7 +515,7 @@ class Expr
* @param mixed $y Argument to be used in LIKE() comparison. * @param mixed $y Argument to be used in LIKE() comparison.
* @return Expr\Comparison * @return Expr\Comparison
*/ */
public static function like($x, $y) public function like($x, $y)
{ {
return new Expr\Comparison($x, 'LIKE', $y); return new Expr\Comparison($x, 'LIKE', $y);
} }
...@@ -527,7 +527,7 @@ class Expr ...@@ -527,7 +527,7 @@ class Expr
* @param mixed $x Second argument to be used in CONCAT() function. * @param mixed $x Second argument to be used in CONCAT() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function concat($x, $y) public function concat($x, $y)
{ {
return new Expr\Func('CONCAT', array($x, $y)); return new Expr\Func('CONCAT', array($x, $y));
} }
...@@ -540,7 +540,7 @@ class Expr ...@@ -540,7 +540,7 @@ class Expr
* @param integer $len Length of crop. May accept negative values. * @param integer $len Length of crop. May accept negative values.
* @return Expr\Func * @return Expr\Func
*/ */
public static function substr($x, $from, $len) public function substr($x, $from, $len)
{ {
return new Expr\Func('SUBSTR', array($x, $from, $len)); return new Expr\Func('SUBSTR', array($x, $from, $len));
} }
...@@ -551,7 +551,7 @@ class Expr ...@@ -551,7 +551,7 @@ class Expr
* @param mixed $x Argument to be used in LOWER() function. * @param mixed $x Argument to be used in LOWER() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function lower($x) public function lower($x)
{ {
return new Expr\Func('LOWER', array($x)); return new Expr\Func('LOWER', array($x));
} }
...@@ -562,7 +562,7 @@ class Expr ...@@ -562,7 +562,7 @@ class Expr
* @param mixed $x Argument to be used in LOWER() function. * @param mixed $x Argument to be used in LOWER() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function upper($x) public function upper($x)
{ {
return new Expr\Func('UPPER', array($x)); return new Expr\Func('UPPER', array($x));
} }
...@@ -573,7 +573,7 @@ class Expr ...@@ -573,7 +573,7 @@ class Expr
* @param mixed $x Argument to be used as argument of LENGTH() function. * @param mixed $x Argument to be used as argument of LENGTH() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function length($x) public function length($x)
{ {
return new Expr\Func('LENGTH', array($x)); return new Expr\Func('LENGTH', array($x));
} }
...@@ -584,7 +584,7 @@ class Expr ...@@ -584,7 +584,7 @@ class Expr
* @param mixed $literal Argument to be converted to literal. * @param mixed $literal Argument to be converted to literal.
* @return string * @return string
*/ */
public static function literal($literal) public function literal($literal)
{ {
if (is_numeric($literal)) { if (is_numeric($literal)) {
return (string) $literal; return (string) $literal;
...@@ -601,7 +601,7 @@ class Expr ...@@ -601,7 +601,7 @@ class Expr
* @param integer $y End point value to be used in BETWEEN() function. * @param integer $y End point value to be used in BETWEEN() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function between($val, $x, $y) public function between($val, $x, $y)
{ {
return new Expr\Func('BETWEEN', array($val, $x, $y)); return new Expr\Func('BETWEEN', array($val, $x, $y));
} }
...@@ -612,7 +612,7 @@ class Expr ...@@ -612,7 +612,7 @@ class Expr
* @param mixed $x Argument to be used as argument of TRIM() function. * @param mixed $x Argument to be used as argument of TRIM() function.
* @return Expr\Func * @return Expr\Func
*/ */
public static function trim($x) public function trim($x)
{ {
return new Expr\Func('TRIM', $x); return new Expr\Func('TRIM', $x);
} }
......
...@@ -83,6 +83,11 @@ class QueryBuilder ...@@ -83,6 +83,11 @@ class QueryBuilder
*/ */
private $_q; private $_q;
/**
* @var Expr The Expr instance used to generate DQL expressions
*/
private $_expr;
/** /**
* Initializes a new <tt>QueryBuilder</tt> that uses the given <tt>EntityManager</tt>. * Initializes a new <tt>QueryBuilder</tt> that uses the given <tt>EntityManager</tt>.
* *
...@@ -94,6 +99,19 @@ class QueryBuilder ...@@ -94,6 +99,19 @@ class QueryBuilder
$this->_q = $entityManager->createQuery(); $this->_q = $entityManager->createQuery();
} }
/**
* Factory for instantiating and retrieving the Expr instance when needed
*
* @return Expr $expr
*/
public function expr()
{
if ( ! $this->_expr) {
$this->_expr = new Expr;
}
return $this->_expr;
}
public function getType() public function getType()
{ {
return $this->_type; return $this->_type;
......
...@@ -43,31 +43,32 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase ...@@ -43,31 +43,32 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
protected function setUp() protected function setUp()
{ {
$this->_em = $this->_getTestEntityManager(); $this->_em = $this->_getTestEntityManager();
$this->_expr = new Expr;
} }
public function testAvgExpr() public function testAvgExpr()
{ {
$this->assertEquals('AVG(u.id)', (string) Expr::avg('u.id')); $this->assertEquals('AVG(u.id)', (string) $this->_expr->avg('u.id'));
} }
public function testMaxExpr() public function testMaxExpr()
{ {
$this->assertEquals('MAX(u.id)', (string) Expr::max('u.id')); $this->assertEquals('MAX(u.id)', (string) $this->_expr->max('u.id'));
} }
public function testMinExpr() public function testMinExpr()
{ {
$this->assertEquals('MIN(u.id)', (string) Expr::min('u.id')); $this->assertEquals('MIN(u.id)', (string) $this->_expr->min('u.id'));
} }
public function testCountExpr() public function testCountExpr()
{ {
$this->assertEquals('MAX(u.id)', (string) Expr::max('u.id')); $this->assertEquals('MAX(u.id)', (string) $this->_expr->max('u.id'));
} }
public function testCountDistinctExpr() public function testCountDistinctExpr()
{ {
$this->assertEquals('COUNT(DISTINCT u.id)', (string) Expr::countDistinct('u.id')); $this->assertEquals('COUNT(DISTINCT u.id)', (string) $this->_expr->countDistinct('u.id'));
} }
public function testExistsExpr() public function testExistsExpr()
...@@ -75,7 +76,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase ...@@ -75,7 +76,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
$qb = $this->_em->createQueryBuilder(); $qb = $this->_em->createQueryBuilder();
$qb->select('u')->from('User', 'u')->where('u.name = ?1'); $qb->select('u')->from('User', 'u')->where('u.name = ?1');
$this->assertEquals('EXISTS(SELECT u FROM User u WHERE u.name = ?1)', (string) Expr::exists($qb)); $this->assertEquals('EXISTS(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->exists($qb));
} }
public function testAllExpr() public function testAllExpr()
...@@ -83,7 +84,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase ...@@ -83,7 +84,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
$qb = $this->_em->createQueryBuilder(); $qb = $this->_em->createQueryBuilder();
$qb->select('u')->from('User', 'u')->where('u.name = ?1'); $qb->select('u')->from('User', 'u')->where('u.name = ?1');
$this->assertEquals('ALL(SELECT u FROM User u WHERE u.name = ?1)', (string) Expr::all($qb)); $this->assertEquals('ALL(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->all($qb));
} }
public function testSomeExpr() public function testSomeExpr()
...@@ -91,7 +92,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase ...@@ -91,7 +92,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
$qb = $this->_em->createQueryBuilder(); $qb = $this->_em->createQueryBuilder();
$qb->select('u')->from('User', 'u')->where('u.name = ?1'); $qb->select('u')->from('User', 'u')->where('u.name = ?1');
$this->assertEquals('SOME(SELECT u FROM User u WHERE u.name = ?1)', (string) Expr::some($qb)); $this->assertEquals('SOME(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->some($qb));
} }
public function testAnyExpr() public function testAnyExpr()
...@@ -99,7 +100,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase ...@@ -99,7 +100,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
$qb = $this->_em->createQueryBuilder(); $qb = $this->_em->createQueryBuilder();
$qb->select('u')->from('User', 'u')->where('u.name = ?1'); $qb->select('u')->from('User', 'u')->where('u.name = ?1');
$this->assertEquals('ANY(SELECT u FROM User u WHERE u.name = ?1)', (string) Expr::any($qb)); $this->assertEquals('ANY(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->any($qb));
} }
public function testNotExpr() public function testNotExpr()
...@@ -107,168 +108,168 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase ...@@ -107,168 +108,168 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
$qb = $this->_em->createQueryBuilder(); $qb = $this->_em->createQueryBuilder();
$qb->select('u')->from('User', 'u')->where('u.name = ?1'); $qb->select('u')->from('User', 'u')->where('u.name = ?1');
$this->assertEquals('NOT(SELECT u FROM User u WHERE u.name = ?1)', (string) Expr::not($qb)); $this->assertEquals('NOT(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->not($qb));
} }
public function testAndExpr() public function testAndExpr()
{ {
$this->assertEquals('(1 = 1) AND (2 = 2)', (string) Expr::andx((string) Expr::eq(1, 1), (string) Expr::eq(2, 2))); $this->assertEquals('(1 = 1) AND (2 = 2)', (string) $this->_expr->andx((string) $this->_expr->eq(1, 1), (string) $this->_expr->eq(2, 2)));
} }
public function testIntelligentParenthesisPreventionAndExpr() public function testIntelligentParenthesisPreventionAndExpr()
{ {
$this->assertEquals( $this->assertEquals(
'(1 = 1) AND (2 = 2)', '(1 = 1) AND (2 = 2)',
(string) Expr::andx(Expr::orx(Expr::andx(Expr::eq(1, 1))), (string) Expr::eq(2, 2)) (string) $this->_expr->andx($this->_expr->orx($this->_expr->andx($this->_expr->eq(1, 1))), (string) $this->_expr->eq(2, 2))
); );
} }
public function testOrExpr() public function testOrExpr()
{ {
$this->assertEquals('(1 = 1) OR (2 = 2)', (string) Expr::orx((string) Expr::eq(1, 1), (string) Expr::eq(2, 2))); $this->assertEquals('(1 = 1) OR (2 = 2)', (string) $this->_expr->orx((string) $this->_expr->eq(1, 1), (string) $this->_expr->eq(2, 2)));
} }
public function testAbsExpr() public function testAbsExpr()
{ {
$this->assertEquals('ABS(1)', (string) Expr::abs(1)); $this->assertEquals('ABS(1)', (string) $this->_expr->abs(1));
} }
public function testProdExpr() public function testProdExpr()
{ {
$this->assertEquals('1 * 2', (string) Expr::prod(1, 2)); $this->assertEquals('1 * 2', (string) $this->_expr->prod(1, 2));
} }
public function testDiffExpr() public function testDiffExpr()
{ {
$this->assertEquals('1 - 2', (string) Expr::diff(1, 2)); $this->assertEquals('1 - 2', (string) $this->_expr->diff(1, 2));
} }
public function testSumExpr() public function testSumExpr()
{ {
$this->assertEquals('1 + 2', (string) Expr::sum(1, 2)); $this->assertEquals('1 + 2', (string) $this->_expr->sum(1, 2));
} }
public function testQuotientExpr() public function testQuotientExpr()
{ {
$this->assertEquals('10 / 2', (string) Expr::quot(10, 2)); $this->assertEquals('10 / 2', (string) $this->_expr->quot(10, 2));
} }
public function testScopeInArithmeticExpr() public function testScopeInArithmeticExpr()
{ {
$this->assertEquals('(100 - 20) / 2', (string) Expr::quot(Expr::diff(100, 20), 2)); $this->assertEquals('(100 - 20) / 2', (string) $this->_expr->quot($this->_expr->diff(100, 20), 2));
$this->assertEquals('100 - (20 / 2)', (string) Expr::diff(100, Expr::quot(20, 2))); $this->assertEquals('100 - (20 / 2)', (string) $this->_expr->diff(100, $this->_expr->quot(20, 2)));
} }
public function testSquareRootExpr() public function testSquareRootExpr()
{ {
$this->assertEquals('SQRT(1)', (string) Expr::sqrt(1)); $this->assertEquals('SQRT(1)', (string) $this->_expr->sqrt(1));
} }
public function testEqualExpr() public function testEqualExpr()
{ {
$this->assertEquals('1 = 1', (string) Expr::eq(1, 1)); $this->assertEquals('1 = 1', (string) $this->_expr->eq(1, 1));
} }
public function testLikeExpr() public function testLikeExpr()
{ {
$this->assertEquals('a.description LIKE :description', (string) Expr::like('a.description', ':description')); $this->assertEquals('a.description LIKE :description', (string) $this->_expr->like('a.description', ':description'));
} }
public function testConcatExpr() public function testConcatExpr()
{ {
$this->assertEquals('CONCAT(u.first_name, u.last_name)', (string) Expr::concat('u.first_name', 'u.last_name')); $this->assertEquals('CONCAT(u.first_name, u.last_name)', (string) $this->_expr->concat('u.first_name', 'u.last_name'));
} }
public function testSubstrExpr() public function testSubstrExpr()
{ {
$this->assertEquals('SUBSTR(a.title, 0, 25)', (string) Expr::substr('a.title', 0, 25)); $this->assertEquals('SUBSTR(a.title, 0, 25)', (string) $this->_expr->substr('a.title', 0, 25));
} }
public function testLowerExpr() public function testLowerExpr()
{ {
$this->assertEquals('LOWER(u.first_name)', (string) Expr::lower('u.first_name')); $this->assertEquals('LOWER(u.first_name)', (string) $this->_expr->lower('u.first_name'));
} }
public function testUpperExpr() public function testUpperExpr()
{ {
$this->assertEquals('UPPER(u.first_name)', (string) Expr::upper('u.first_name')); $this->assertEquals('UPPER(u.first_name)', (string) $this->_expr->upper('u.first_name'));
} }
public function testLengthExpr() public function testLengthExpr()
{ {
$this->assertEquals('LENGTH(u.first_name)', (string) Expr::length('u.first_name')); $this->assertEquals('LENGTH(u.first_name)', (string) $this->_expr->length('u.first_name'));
} }
public function testGreaterThanExpr() public function testGreaterThanExpr()
{ {
$this->assertEquals('5 > 2', (string) Expr::gt(5, 2)); $this->assertEquals('5 > 2', (string) $this->_expr->gt(5, 2));
} }
public function testLessThanExpr() public function testLessThanExpr()
{ {
$this->assertEquals('2 < 5', (string) Expr::lt(2, 5)); $this->assertEquals('2 < 5', (string) $this->_expr->lt(2, 5));
} }
public function testStringLiteralExpr() public function testStringLiteralExpr()
{ {
$this->assertEquals("'word'", (string) Expr::literal('word')); $this->assertEquals("'word'", (string) $this->_expr->literal('word'));
} }
public function testNumericLiteralExpr() public function testNumericLiteralExpr()
{ {
$this->assertEquals(5, (string) Expr::literal(5)); $this->assertEquals(5, (string) $this->_expr->literal(5));
} }
public function testGreaterThanOrEqualToExpr() public function testGreaterThanOrEqualToExpr()
{ {
$this->assertEquals('5 >= 2', (string) Expr::gte(5, 2)); $this->assertEquals('5 >= 2', (string) $this->_expr->gte(5, 2));
} }
public function testLessThanOrEqualTo() public function testLessThanOrEqualTo()
{ {
$this->assertEquals('2 <= 5', (string) Expr::lte(2, 5)); $this->assertEquals('2 <= 5', (string) $this->_expr->lte(2, 5));
} }
public function testBetweenExpr() public function testBetweenExpr()
{ {
$this->assertEquals('BETWEEN(u.id, 3, 6)', (string) Expr::between('u.id', 3, 6)); $this->assertEquals('BETWEEN(u.id, 3, 6)', (string) $this->_expr->between('u.id', 3, 6));
} }
public function testTrimExpr() public function testTrimExpr()
{ {
$this->assertEquals('TRIM(u.id)', (string) Expr::trim('u.id')); $this->assertEquals('TRIM(u.id)', (string) $this->_expr->trim('u.id'));
} }
public function testInExpr() public function testInExpr()
{ {
$this->assertEquals('u.id IN(1, 2, 3)', (string) Expr::in('u.id', array(1, 2, 3))); $this->assertEquals('u.id IN(1, 2, 3)', (string) $this->_expr->in('u.id', array(1, 2, 3)));
} }
public function testAndxOrxExpr() public function testAndxOrxExpr()
{ {
$andExpr = Expr::andx(); $andExpr = $this->_expr->andx();
$andExpr->add(Expr::eq(1, 1)); $andExpr->add($this->_expr->eq(1, 1));
$andExpr->add(Expr::lt(1, 5)); $andExpr->add($this->_expr->lt(1, 5));
$orExpr = Expr::orx(); $orExpr = $this->_expr->orx();
$orExpr->add($andExpr); $orExpr->add($andExpr);
$orExpr->add(Expr::eq(1, 1)); $orExpr->add($this->_expr->eq(1, 1));
$this->assertEquals('((1 = 1) AND (1 < 5)) OR (1 = 1)', (string) $orExpr); $this->assertEquals('((1 = 1) AND (1 < 5)) OR (1 = 1)', (string) $orExpr);
} }
public function testOrxExpr() public function testOrxExpr()
{ {
$orExpr = Expr::orx(); $orExpr = $this->_expr->orx();
$orExpr->add(Expr::eq(1, 1)); $orExpr->add($this->_expr->eq(1, 1));
$orExpr->add(Expr::lt(1, 5)); $orExpr->add($this->_expr->lt(1, 5));
$this->assertEquals('(1 = 1) OR (1 < 5)', (string) $orExpr); $this->assertEquals('(1 = 1) OR (1 < 5)', (string) $orExpr);
} }
public function testSelectExpr() public function testSelectExpr()
{ {
$selectExpr = Expr::select(); $selectExpr = $this->_expr->select();
$selectExpr->add('u.id'); $selectExpr->add('u.id');
$selectExpr->add('u.username'); $selectExpr->add('u.username');
...@@ -277,13 +278,13 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase ...@@ -277,13 +278,13 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
public function testFromExpr() public function testFromExpr()
{ {
$this->assertEquals('User', (string) Expr::from('User')); $this->assertEquals('User', (string) $this->_expr->from('User'));
$this->assertEquals('User u', (string) Expr::from('User', 'u')); $this->assertEquals('User u', (string) $this->_expr->from('User', 'u'));
} }
public function testExprBaseCount() public function testExprBaseCount()
{ {
$selectExpr = Expr::select(); $selectExpr = $this->_expr->select();
$selectExpr->add('u.id'); $selectExpr->add('u.id');
$selectExpr->add('u.username'); $selectExpr->add('u.username');
...@@ -292,7 +293,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase ...@@ -292,7 +293,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
public function testOrderByCountExpr() public function testOrderByCountExpr()
{ {
$orderByExpr = Expr::orderBy(); $orderByExpr = $this->_expr->orderBy();
$orderByExpr->add('u.username', 'DESC'); $orderByExpr->add('u.username', 'DESC');
$this->assertEquals($orderByExpr->count(), 1); $this->assertEquals($orderByExpr->count(), 1);
...@@ -301,13 +302,13 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase ...@@ -301,13 +302,13 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
public function testOrderByOrder() public function testOrderByOrder()
{ {
$orderByExpr = Expr::orderBy('u.username', 'DESC'); $orderByExpr = $this->_expr->orderBy('u.username', 'DESC');
$this->assertEquals('u.username DESC', (string) $orderByExpr); $this->assertEquals('u.username DESC', (string) $orderByExpr);
} }
public function testOrderByDefaultOrderIsAsc() public function testOrderByDefaultOrderIsAsc()
{ {
$orderByExpr = Expr::orderBy('u.username'); $orderByExpr = $this->_expr->orderBy('u.username');
$this->assertEquals('u.username ASC', (string) $orderByExpr); $this->assertEquals('u.username ASC', (string) $orderByExpr);
} }
...@@ -316,7 +317,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase ...@@ -316,7 +317,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
*/ */
public function testAddThrowsException() public function testAddThrowsException()
{ {
$orExpr = Expr::orx(); $orExpr = $this->_expr->orx();
$orExpr->add(Expr::quot(5, 2)); $orExpr->add($this->_expr->quot(5, 2));
} }
} }
\ No newline at end of file
...@@ -183,44 +183,44 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase ...@@ -183,44 +183,44 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
public function testAndWhereIn() public function testAndWhereIn()
{ {
$qb = $this->_em->createQueryBuilder() $qb = $this->_em->createQueryBuilder();
->select('u') $qb->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->where('u.id = :uid') ->where('u.id = :uid')
->andWhere(Expr::in('u.id', array(1, 2, 3))); ->andWhere($qb->expr()->in('u.id', array(1, 2, 3)));
$this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) AND (u.id IN(1, 2, 3))'); $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) AND (u.id IN(1, 2, 3))');
} }
public function testOrWhereIn() public function testOrWhereIn()
{ {
$qb = $this->_em->createQueryBuilder() $qb = $this->_em->createQueryBuilder();
->select('u') $qb->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->where('u.id = :uid') ->where('u.id = :uid')
->orWhere(Expr::in('u.id', array(1, 2, 3))); ->orWhere($qb->expr()->in('u.id', array(1, 2, 3)));
$this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) OR (u.id IN(1, 2, 3))'); $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) OR (u.id IN(1, 2, 3))');
} }
public function testAndWhereNotIn() public function testAndWhereNotIn()
{ {
$qb = $this->_em->createQueryBuilder() $qb = $this->_em->createQueryBuilder();
->select('u') $qb->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->where('u.id = :uid') ->where('u.id = :uid')
->andWhere(Expr::notIn('u.id', array(1, 2, 3))); ->andWhere($qb->expr()->notIn('u.id', array(1, 2, 3)));
$this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) AND (u.id NOT IN(1, 2, 3))'); $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) AND (u.id NOT IN(1, 2, 3))');
} }
public function testOrWhereNotIn() public function testOrWhereNotIn()
{ {
$qb = $this->_em->createQueryBuilder() $qb = $this->_em->createQueryBuilder();
->select('u') $qb->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->where('u.id = :uid') ->where('u.id = :uid')
->OrWhere(Expr::notIn('u.id', array(1, 2, 3))); ->orWhere($qb->expr()->notIn('u.id', array(1, 2, 3)));
$this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) OR (u.id NOT IN(1, 2, 3))'); $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) OR (u.id NOT IN(1, 2, 3))');
} }
...@@ -316,10 +316,10 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase ...@@ -316,10 +316,10 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
public function testSetParameters() public function testSetParameters()
{ {
$qb = $this->_em->createQueryBuilder() $qb = $this->_em->createQueryBuilder();
->select('u') $qb->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->where(Expr::orx('u.username = :username', 'u.username = :username2')); ->where($qb->expr()->orx('u.username = :username', 'u.username = :username2'));
$qb->setParameters(array('username' => 'jwage', 'username2' => 'jonwage')); $qb->setParameters(array('username' => 'jwage', 'username2' => 'jonwage'));
...@@ -329,8 +329,8 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase ...@@ -329,8 +329,8 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
public function testGetParameters() public function testGetParameters()
{ {
$qb = $this->_em->createQueryBuilder() $qb = $this->_em->createQueryBuilder();
->select('u') $qb->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->where('u.id = :id'); ->where('u.id = :id');
...@@ -371,22 +371,22 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase ...@@ -371,22 +371,22 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
public function testMultipleOrWhere() public function testMultipleOrWhere()
{ {
$qb = $this->_em->createQueryBuilder() $qb = $this->_em->createQueryBuilder();
->select('u') $qb->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->orWhere('u.id = :uid', Expr::eq('u.id', ':uid2')); ->orWhere('u.id = :uid', $qb->expr()->eq('u.id', ':uid2'));
$this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) OR (u.id = :uid2)'); $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) OR (u.id = :uid2)');
} }
public function testComplexWhere() public function testComplexWhere()
{ {
$orExpr = Expr::orx(); $qb = $this->_em->createQueryBuilder();
$orExpr->add(Expr::eq('u.id', ':uid3')); $orExpr = $qb->expr()->orx();
$orExpr->add(Expr::in('u.id', array(1))); $orExpr->add($qb->expr()->eq('u.id', ':uid3'));
$orExpr->add($qb->expr()->in('u.id', array(1)));
$qb = $this->_em->createQueryBuilder() $qb->select('u')
->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->where($orExpr); ->where($orExpr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment