From b144321c76c2e52127b4640d685dea8eebfc0fdf Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 24 Feb 2014 00:15:38 +0100 Subject: [PATCH] New Sql operators, because they may come in handy --- .../MiscOperators/SqlIfNullOperator.php | 17 +++++++++++++++++ .../Operators/UnaryOperators/SqlMaxOperator.php | 8 ++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/Sql/Operators/MiscOperators/SqlIfNullOperator.php create mode 100644 src/Sql/Operators/UnaryOperators/SqlMaxOperator.php diff --git a/src/Sql/Operators/MiscOperators/SqlIfNullOperator.php b/src/Sql/Operators/MiscOperators/SqlIfNullOperator.php new file mode 100644 index 00000000..b2fbe9ef --- /dev/null +++ b/src/Sql/Operators/MiscOperators/SqlIfNullOperator.php @@ -0,0 +1,17 @@ +subject = $this->attachExpression($subject); + $this->target = $this->attachExpression($target); + } + + public function getAsString() + { + return 'IFNULL (' . $this->subject->getAsString() . ', ' . $this->target->getAsString() . ')'; + } +} diff --git a/src/Sql/Operators/UnaryOperators/SqlMaxOperator.php b/src/Sql/Operators/UnaryOperators/SqlMaxOperator.php new file mode 100644 index 00000000..0b9a12b3 --- /dev/null +++ b/src/Sql/Operators/UnaryOperators/SqlMaxOperator.php @@ -0,0 +1,8 @@ +subject->getAsString() . ')'; + } +}