1
0
mirror of synced 2024-12-14 07:06:04 +03:00

Added NOT LIKE expression

This commit is contained in:
Martin Hasoň 2012-10-25 12:58:19 +02:00
parent f5c1b38e2d
commit 7f33143502
2 changed files with 18 additions and 1 deletions

View File

@ -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 <guilhermeblanco@hotmail.com>
@ -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.
*

View File

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