summaryrefslogtreecommitdiffstats
path: root/src/Components/UnionKeyword.php
blob: cbdb52913820c598831739bac71d0bfe3dd20133 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

/**
 * `UNION` keyword builder.
 *
 * @package    SqlParser
 * @subpackage Components
 */
namespace SqlParser\Components;

use SqlParser\Component;
use SqlParser\Statements\SelectStatement;

/**
 * `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);
    }
}