Completed
Push — master ( 46dbb7...9c8538 )
by Hong
02:48
created

Insert::getConfigs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
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
/**
26
 * Insert
27
 *
28
 * @package Phossa2\Query
29
 * @author  Hong Zhang <[email protected]>
30
 * @see     StatementAbstract
31
 * @see     InsertStatementInterface
32
 * @see     SelectStatementInterface
33
 * @version 2.0.0
34
 * @since   2.0.0 added
35
 */
36
class Insert extends StatementAbstract implements InsertStatementInterface
37
{
38
    use ClauseTrait, TableTrait, SetTrait;
39
40
    /**
41
     * {@inheritDoc}
42
     */
43
    public function into(/*# string */ $table)
44
    {
45
        return $this->table($table);
46
    }
47
48
    /**
49
     * INSERT ... SELECT
50
     *
51
     * {@inheritDoc}
52
     */
53
    public function select()/*# : SelectStatementInterface */ {
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