1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of UnderQuery package. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2016 Beniamin Jonatan Šimko |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Phuria\UnderQuery\QueryCompiler\ConcreteCompiler; |
13
|
|
|
|
14
|
|
|
use Phuria\UnderQuery\QueryBuilder\BuilderInterface; |
15
|
|
|
use Phuria\UnderQuery\QueryBuilder\SelectBuilder; |
16
|
|
|
use Phuria\UnderQuery\QueryCompiler\ClausesCompiler; |
17
|
|
|
use Phuria\UnderQuery\QueryCompiler\CompilerPayload; |
18
|
|
|
use Phuria\UnderQuery\QueryCompiler\ReferenceCompiler; |
19
|
|
|
use Phuria\UnderQuery\QueryCompiler\TableCompiler; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author Beniamin Jonatan Šimko <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class SelectCompiler extends AbstractConcreteCompiler |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* SelectCompiler constructor. |
28
|
|
|
*/ |
29
|
|
|
public function __construct() |
30
|
|
|
{ |
31
|
|
|
$tableCompiler = new TableCompiler(); |
32
|
|
|
$referenceCompiler = new ReferenceCompiler(); |
33
|
|
|
$clauseCompiler = new ClausesCompiler(); |
34
|
|
|
|
35
|
|
|
parent::__construct([ |
36
|
|
|
[$clauseCompiler, 'compileSelect'], |
37
|
|
|
[$tableCompiler, 'compileRootTables'], |
38
|
|
|
[$tableCompiler, 'compileJoinTables'], |
39
|
|
|
[$clauseCompiler, 'compileWhere'], |
40
|
|
|
[$clauseCompiler, 'compileGroupBy'], |
41
|
|
|
[$clauseCompiler, 'compileHaving'], |
42
|
|
|
[$clauseCompiler, 'compileOrderBy'], |
43
|
|
|
[$clauseCompiler, 'compileLimit'], |
44
|
|
|
[$referenceCompiler, 'compileReference'], |
45
|
|
|
]); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @inheritdoc |
50
|
|
|
*/ |
51
|
|
|
public function supportsBuilder(BuilderInterface $builder) |
52
|
|
|
{ |
53
|
|
|
return $builder instanceof SelectBuilder; |
54
|
|
|
} |
55
|
|
|
} |