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'));