@@ 12-43 (lines=32) @@ | ||
9 | * |
|
10 | * @author David Négrier <[email protected]> |
|
11 | */ |
|
12 | class Different extends AbstractTwoOperandsOperator |
|
13 | { |
|
14 | /** |
|
15 | * Returns the symbol for this operator. |
|
16 | * |
|
17 | * @return string |
|
18 | */ |
|
19 | protected function getOperatorSymbol() |
|
20 | { |
|
21 | return '<>'; |
|
22 | } |
|
23 | ||
24 | protected function getSql(array $parameters = array(), Connection $dbConnection = null, $indent = 0, $conditionsMode = self::CONDITION_APPLY) |
|
25 | { |
|
26 | $rightOperand = $this->getRightOperand(); |
|
27 | if ($rightOperand instanceof Parameter && !isset($parameters[$rightOperand->getName()])) { |
|
28 | $isNull = true; |
|
29 | } else { |
|
30 | $isNull = false; |
|
31 | } |
|
32 | ||
33 | $sql = NodeFactory::toSql($this->getLeftOperand(), $dbConnection, $parameters, ' ', false, $indent, $conditionsMode); |
|
34 | if ($isNull) { |
|
35 | $sql .= ' IS NOT null'; |
|
36 | } else { |
|
37 | $sql .= ' '.$this->getOperatorSymbol().' '; |
|
38 | $sql .= NodeFactory::toSql($rightOperand, $dbConnection, $parameters, ' ', false, $indent, $conditionsMode); |
|
39 | } |
|
40 | ||
41 | return $sql; |
|
42 | } |
|
43 | } |
|
44 |
@@ 12-41 (lines=30) @@ | ||
9 | * |
|
10 | * @author David Négrier <[email protected]> |
|
11 | */ |
|
12 | class Equal extends AbstractTwoOperandsOperator |
|
13 | { |
|
14 | /** |
|
15 | * Returns the symbol for this operator. |
|
16 | */ |
|
17 | protected function getOperatorSymbol() |
|
18 | { |
|
19 | return '='; |
|
20 | } |
|
21 | ||
22 | protected function getSql(array $parameters = array(), Connection $dbConnection = null, $indent = 0, $conditionsMode = self::CONDITION_APPLY) |
|
23 | { |
|
24 | $rightOperand = $this->getRightOperand(); |
|
25 | if ($rightOperand instanceof Parameter && !isset($parameters[$rightOperand->getName()])) { |
|
26 | $isNull = true; |
|
27 | } else { |
|
28 | $isNull = false; |
|
29 | } |
|
30 | ||
31 | $sql = NodeFactory::toSql($this->getLeftOperand(), $dbConnection, $parameters, ' ', false, $indent, $conditionsMode); |
|
32 | if ($isNull) { |
|
33 | $sql .= ' IS null'; |
|
34 | } else { |
|
35 | $sql .= ' '.$this->getOperatorSymbol().' '; |
|
36 | $sql .= NodeFactory::toSql($rightOperand, $dbConnection, $parameters, ' ', false, $indent, $conditionsMode); |
|
37 | } |
|
38 | ||
39 | return $sql; |
|
40 | } |
|
41 | } |
|
42 |