Completed
Push — resets ( d2f77b )
by Paul
02:06
created

Insert::getLastInsertIdName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 *
4
 * This file is part of Aura for PHP.
5
 *
6
 * @license http://opensource.org/licenses/bsd-license.php BSD
7
 *
8
 */
9
namespace Aura\SqlQuery\Pgsql;
10
11
use Aura\SqlQuery\Common;
12
13
/**
14
 *
15
 * An object for PgSQL INSERT queries.
16
 *
17
 * @package Aura.SqlQuery
18
 *
19
 */
20
class Insert extends Common\Insert implements Common\ReturningInterface
21
{
22
    /**
23
     *
24
     * Returns the proper name for passing to `PDO::lastInsertId()`.
25
     *
26
     * @param string $col The last insert ID column.
27
     *
28
     * @return string The sequence name "{$into_table}_{$col}_seq", or the
29
     * value from `$last_insert_id_names`.
30
     *
31
     */
32 2
    public function getLastInsertIdName($col)
33
    {
34 2
        $name = parent::getLastInsertIdName($col);
35 2
        if (! $name) {
36 1
            $name = "{$this->into}_{$col}_seq";
37 1
        }
38 2
        return $name;
39
    }
40
41
    /**
42
     *
43
     * Adds returning columns to the query.
44
     *
45
     * Multiple calls to returning() will append to the list of columns, not
46
     * overwrite the previous columns.
47
     *
48
     * @param array $cols The column(s) to add to the query.
49
     *
50
     * @return $this
51
     *
52
     */
53 1
    public function returning(array $cols)
54
    {
55 1
        return $this->addReturning($cols);
56
    }
57
}
58