summaryrefslogtreecommitdiffstats
path: root/src/Components
diff options
context:
space:
mode:
authorDan Ungureanu <udan1107@gmail.com>2015-07-25 14:19:28 +0300
committerDan Ungureanu <udan1107@gmail.com>2015-07-25 14:19:28 +0300
commit6e335616597277d0687bd036fc9acc05386369a0 (patch)
treea8ee43ace199160a54eceb04f0f26fa25117d42d /src/Components
parentfc390a8d2af884f5f81dd313687046932a833b2e (diff)
downloadsql-parser-6e335616597277d0687bd036fc9acc05386369a0.zip
sql-parser-6e335616597277d0687bd036fc9acc05386369a0.tar.gz
sql-parser-6e335616597277d0687bd036fc9acc05386369a0.tar.bz2
Improved support for UNION.
Diffstat (limited to 'src/Components')
-rw-r--r--src/Components/UnionKeyword.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/Components/UnionKeyword.php b/src/Components/UnionKeyword.php
new file mode 100644
index 0000000..5a247bc
--- /dev/null
+++ b/src/Components/UnionKeyword.php
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * `UNION` keyword builder.
+ *
+ * @package SqlParser
+ * @subpackage Components
+ */
+namespace SqlParser\Components;
+
+use SqlParser\Component;
+use SqlParser\Parser;
+use SqlParser\Token;
+use SqlParser\TokensList;
+
+/**
+ * `UNION` keyword builder.
+ *
+ * @category Keywords
+ * @package SqlParser
+ * @subpackage Components
+ * @author Dan Ungureanu <udan1107@gmail.com>
+ * @license http://opensource.org/licenses/GPL-2.0 GNU Public License
+ */
+class UnionKeyword extends Component
+{
+
+ /**
+ * @param SelectStatement[] $component The component to be built.
+ *
+ * @return string
+ */
+ public static function build($component)
+ {
+ $ret = array();
+ foreach ($component as $c) {
+ $ret[] = $c->build();
+ }
+ return implode(" UNION ", $ret);
+ }
+}