. */ namespace Doctrine\ORM\Query; /** * This class is used to generate DQL expressions via a set of PHP static functions * * @author Jonathan H. Wage * @author Roman Borschel * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link http://www.phpdoctrine.org * @since 2.0 * @version $Revision$ */ class Expr { public static function andx($x = null) { return new Expr\Andx(func_get_args()); } public static function orx($x = null) { return new Expr\Orx(func_get_args()); } public static function select($select = null) { return new Expr\Select(func_get_args()); } public static function orderBy($sort = null, $order = null) { return new Expr\OrderBy($sort, $order); } public static function groupBy($groupBy = null) { return new Expr\GroupBy(func_get_args()); } public static function having($having = null) { return new Expr\Having(func_get_args()); } public static function eq($x, $y) { return new Expr\Comparison($x, '=', $y); } public static function neq($x, $y) { return new Expr\Comparison($x, '<>', $y); } public static function lt($x, $y) { return new Expr\Comparison($x, '<', $y); } public static function lte($x, $y) { return new Expr\Comparison($x, '<=', $y); } public static function gt($x, $y) { return new Expr\Comparison($x, '>', $y); } public static function gte($x, $y) { return new Expr\Comparison($x, '>=', $y); } public static function avg($x) { return new Expr\Func('AVG', array($x)); } public static function max($x) { return new Expr\Func('MAX', array($x)); } public static function min($x) { return new Expr\Func('MIN', array($x)); } public static function count($x) { return new Expr\Func('COUNT', array($x)); } public static function countDistinct() { return 'COUNT(DISTINCT ' . implode(', ', func_get_args()) . ')'; } public static function exists($subquery) { return new Expr\Func('EXISTS', array($subquery)); } public static function all($subquery) { return new Expr\Func('ALL', array($subquery)); } public static function some($subquery) { return new Expr\Func('SOME', array($subquery)); } public static function any($subquery) { return new Expr\Func('ANY', array($subquery)); } public static function not($restriction) { return new Expr\Func('NOT', array($restriction)); } public static function abs($x) { return new Expr\Func('ABS', array($x)); } public static function prod($x, $y) { return new Expr\Math($x, '*', $y); } public static function diff($x, $y) { return new Expr\Math($x, '-', $y); } public static function sum($x, $y) { return new Expr\Math($x, '+', $y); } public static function quot($x, $y) { return new Expr\Math($x, '/', $y); } public static function sqrt($x) { return new Expr\Func('SQRT', array($x)); } public static function in($x, $y) { return new Expr\Func($x . ' IN', (array) $y); } public static function notIn($x, $y) { return new Expr\Func($x . ' NOT IN', (array) $y); } public static function notEqual($x, $y) { return new Expr\Comparison($x, '!=', $y); } public static function like($x, $y) { return new Expr\Math($x, 'LIKE', $y); } public static function concat($x, $y) { return new Expr\Func('CONCAT', array($x, $y)); } public static function substr($x, $from, $len) { return new Expr\Func('SUBSTR', array($x, $from, $len)); } public static function lower($x) { return new Expr\Func('LOWER', array($x)); } public static function upper($x) { return new Expr\Func('UPPER', array($x)); } public static function length($x) { return new Expr\Func('LENGTH', array($x)); } public static function literal($literal) { if (is_numeric($literal)) { return (string) $literal; } else { return "'" . $literal . "'"; } } public static function between($val, $x, $y) { return new Expr\Func('BETWEEN', array($val, $x, $y)); } public static function trim() { return new Expr\Func('TRIM', func_get_args()); } }