Completed
Pull Request — 3.x (#184)
by
unknown
01:29
created

Select   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 36
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A lateralJoinSubSelect() 0 12 1
1
<?php
2
/**
3
 *
4
 * This file is part of Aura for PHP.
5
 *
6
 * @license http://opensource.org/licenses/mit-license.php MIT
7
 *
8
 */
9
namespace Aura\SqlQuery\Pgsql;
10
11
use Aura\SqlQuery\Common;
12
13
/**
14
 *
15
 * An object for PgSQL SELECT queries.
16
 *
17
 * @package Aura.SqlQuery
18
 *
19
 */
20
class Select extends Common\Select
21
{
22
    /**
23
     *
24
     * Adds a LATERAL JOIN to an aliased subselect and columns to the query.
25
     *
26
     * @param string $join The join type: inner, left, natural, etc.
27
     *
28
     * @param string|Select $spec If a Select
29
     * object, use as the sub-select; if a string, the sub-select
30
     * command string.
31
     *
32
     * @param string $name The alias name for the sub-select.
33
     *
34
     * @param string $cond Join on this condition.
35
     *
36
     * @param array $bind Values to bind to ?-placeholders in the condition.
37
     *
38
     * @return $this
39
     *
40
     * @throws Exception
41
     *
42
     */
43
    public function lateralJoinSubSelect($join, $spec, $name, $cond = null, array $bind = array())
44
    {
45
        $join = strtoupper(ltrim("$join JOIN LATERAL"));
46
        $this->addTableRef("$join (SELECT ...) AS", $name);
47
48
        $spec = $this->subSelect($spec, '            ');
49
        $name = $this->quoter->quoteName($name);
50
        $cond = $this->fixJoinCondition($cond, $bind);
51
52
        $text = rtrim("$join ($spec        ) $name $cond");
53
        return $this->addJoin('        ' . $text);
54
    }
55
}
56