Insert::select()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Query
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Query\Dialect\Common;
16
17
use Phossa2\Query\Traits\Clause\SetTrait;
18
use Phossa2\Query\Traits\Clause\TableTrait;
19
use Phossa2\Query\Traits\StatementAbstract;
20
use Phossa2\Query\Traits\Clause\ClauseTrait;
21
use Phossa2\Query\Interfaces\Statement\InsertStatementInterface;
22
use Phossa2\Query\Interfaces\Statement\SelectStatementInterface;
23
24
/**
25
 * Insert
26
 *
27
 * @package Phossa2\Query
28
 * @author  Hong Zhang <[email protected]>
29
 * @see     StatementAbstract
30
 * @see     InsertStatementInterface
31
 * @see     SelectStatementInterface
32
 * @version 2.0.0
33
 * @since   2.0.0 added
34
 */
35
class Insert extends StatementAbstract implements InsertStatementInterface
36
{
37
    use ClauseTrait, TableTrait, SetTrait;
38
39
    /**
40
     * {@inheritDoc}
41
     */
42
    public function into(/*# string */ $table)
43
    {
44
        return $this->table($table);
45
    }
46
47
    /**
48
     * INSERT ... SELECT
49
     *
50
     * {@inheritDoc}
51
     */
52
    public function select()/*# : SelectStatementInterface */
53
    {
54
        return $this->getBuilder()->select()
55
            ->setPrevious($this)    // previous stmt is INSERT
56
            ->col(func_get_args())  // cols from select()
57
            ->table('');            // clear table list
58
    }
59
60
    /**
61
     * {@inheritDoc}
62
     */
63
    protected function getConfigs()/*# : array */
64
    {
65
        return [
66
            'TABLE' => 'INTO',
67
            'SET' => '',
68
            'VALUES' => 'VALUES',
69
        ];
70
    }
71
72
    /**
73
     * {@inheritDoc}
74
     */
75
    protected function getType()/*# : string */
76
    {
77
        return 'INSERT';
78
    }
79
}
80