From 7f331435027c15f3113a5d49fbbeacf753807491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Thu, 25 Oct 2012 12:58:19 +0200 Subject: [PATCH] Added NOT LIKE expression --- lib/Doctrine/ORM/Query/Expr.php | 14 +++++++++++++- tests/Doctrine/Tests/ORM/Query/ExprTest.php | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Query/Expr.php b/lib/Doctrine/ORM/Query/Expr.php index 5ffedba9f..db461f9fd 100644 --- a/lib/Doctrine/ORM/Query/Expr.php +++ b/lib/Doctrine/ORM/Query/Expr.php @@ -22,7 +22,7 @@ namespace Doctrine\ORM\Query; /** * This class is used to generate DQL expressions via a set of PHP static functions * - * + * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -479,6 +479,18 @@ class Expr return new Expr\Comparison($x, 'LIKE', $y); } + /** + * Creates a NOT LIKE() comparison expression with the given arguments. + * + * @param string $x Field in string format to be inspected by LIKE() comparison. + * @param mixed $y Argument to be used in LIKE() comparison. + * @return Expr\Comparison + */ + public function notLike($x, $y) + { + return new Expr\Comparison($x, 'NOT LIKE', $y); + } + /** * Creates a CONCAT() function expression with the given arguments. * diff --git a/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/tests/Doctrine/Tests/ORM/Query/ExprTest.php index 122b98f03..d35944bf8 100644 --- a/tests/Doctrine/Tests/ORM/Query/ExprTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ExprTest.php @@ -173,6 +173,11 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase $this->assertEquals('a.description LIKE :description', (string) $this->_expr->like('a.description', ':description')); } + public function testNotLikeExpr() + { + $this->assertEquals('a.description NOT LIKE :description', (string) $this->_expr->notLike('a.description', ':description')); + } + public function testConcatExpr() { $this->assertEquals('CONCAT(u.first_name, u.last_name)', (string) $this->_expr->concat('u.first_name', 'u.last_name'));