| @@ 33-75 (lines=43) @@ | ||
| 30 | * @author "David Kalosi" <[email protected]> |
|
| 31 | * @license <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> |
|
| 32 | */ |
|
| 33 | class Equals extends OrmCriteria |
|
| 34 | { |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @var OrmProperty |
|
| 38 | */ |
|
| 39 | private $propertyName; |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @var mixed |
|
| 43 | */ |
|
| 44 | private $expression; |
|
| 45 | ||
| 46 | /** |
|
| 47 | * Initializes an Equals operator matching the given <code>property</code> against the given |
|
| 48 | * <code>expression</code>. |
|
| 49 | * |
|
| 50 | * @param OrmProperty $property The property to match |
|
| 51 | * @param mixed $expression The expression to match against. May be <code>null</code>. |
|
| 52 | */ |
|
| 53 | public function __construct(OrmProperty $property, $expression) |
|
| 54 | { |
|
| 55 | $this->propertyName = $property; |
|
| 56 | $this->expression = $expression; |
|
| 57 | } |
|
| 58 | ||
| 59 | public function parse($entryKey, &$whereClause, ParameterRegistry $parameters) |
|
| 60 | { |
|
| 61 | $this->propertyName->parse($entryKey, $whereClause); |
|
| 62 | ||
| 63 | if (null === $this->expression) { |
|
| 64 | $whereClause .= " IS NULL"; |
|
| 65 | } else { |
|
| 66 | $whereClause .= " = "; |
|
| 67 | if ($this->expression instanceof OrmProperty) { |
|
| 68 | $this->expression->parse($entryKey, $whereClause); |
|
| 69 | } else { |
|
| 70 | $whereClause .= $parameters->register($this->expression); |
|
| 71 | } |
|
| 72 | } |
|
| 73 | } |
|
| 74 | ||
| 75 | } |
|
| 76 | ||
| @@ 33-76 (lines=44) @@ | ||
| 30 | * @author "David Kalosi" <[email protected]> |
|
| 31 | * @license <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> |
|
| 32 | */ |
|
| 33 | class NotEquals extends OrmCriteria |
|
| 34 | { |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @var OrmProperty |
|
| 38 | */ |
|
| 39 | private $propertyName; |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @var mixed |
|
| 43 | */ |
|
| 44 | private $expression; |
|
| 45 | ||
| 46 | /** |
|
| 47 | * Initializes an Equals operator matching the given <code>property</code> against the given |
|
| 48 | * <code>expression</code>. |
|
| 49 | * |
|
| 50 | * @param OrmProperty $property The property to match |
|
| 51 | * @param mixed $expression The expression to match against. May be <code>null</code>. |
|
| 52 | */ |
|
| 53 | public function __construct(OrmProperty $property, $expression) |
|
| 54 | { |
|
| 55 | $this->propertyName = $property; |
|
| 56 | $this->expression = $expression; |
|
| 57 | } |
|
| 58 | ||
| 59 | public function parse($entryKey, &$whereClause, |
|
| 60 | ParameterRegistry $parameters) |
|
| 61 | { |
|
| 62 | $this->propertyName->parse($entryKey, $whereClause); |
|
| 63 | ||
| 64 | if (null === $this->expression) { |
|
| 65 | $whereClause .= " IS NOT NULL"; |
|
| 66 | } else { |
|
| 67 | $whereClause .= " <> "; |
|
| 68 | if ($this->expression instanceof OrmProperty) { |
|
| 69 | $this->expression->parse($entryKey, $whereClause); |
|
| 70 | } else { |
|
| 71 | $whereClause .= $parameters->register($this->expression); |
|
| 72 | } |
|
| 73 | } |
|
| 74 | } |
|
| 75 | ||
| 76 | } |
|
| 77 | ||