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\ColTrait; |
18
|
|
|
use Phossa2\Query\Traits\Clause\TableTrait; |
19
|
|
|
use Phossa2\Query\Traits\Clause\JoinTrait; |
20
|
|
|
use Phossa2\Query\Traits\StatementAbstract; |
21
|
|
|
use Phossa2\Query\Traits\Clause\WhereTrait; |
22
|
|
|
use Phossa2\Query\Traits\Clause\LimitTrait; |
23
|
|
|
use Phossa2\Query\Traits\Clause\UnionTrait; |
24
|
|
|
use Phossa2\Query\Traits\Clause\ClauseTrait; |
25
|
|
|
use Phossa2\Query\Traits\Clause\HavingTrait; |
26
|
|
|
use Phossa2\Query\Traits\Clause\GroupTrait; |
27
|
|
|
use Phossa2\Query\Traits\Clause\OrderTrait; |
28
|
|
|
use Phossa2\Query\Interfaces\Statement\SelectStatementInterface; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Select |
32
|
|
|
* |
33
|
|
|
* Implementation of SelectStatementInterface for Common dialect |
34
|
|
|
* |
35
|
|
|
* @package Phossa2\Query |
36
|
|
|
* @author Hong Zhang <[email protected]> |
37
|
|
|
* @see StatementAbstract |
38
|
|
|
* @see SelectStatementInterface |
39
|
|
|
* @version 2.0.0 |
40
|
|
|
* @since 2.0.0 added |
41
|
|
|
*/ |
42
|
|
|
class Select extends StatementAbstract implements SelectStatementInterface |
43
|
|
|
{ |
44
|
|
|
use ClauseTrait, ColTrait, TableTrait, WhereTrait, JoinTrait, |
45
|
|
|
GroupTrait, HavingTrait, OrderTrait, LimitTrait, UnionTrait; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* {@inheritDoc} |
49
|
|
|
*/ |
50
|
|
View Code Duplication |
protected function getConfigs()/*# : array */ |
|
|
|
|
51
|
|
|
{ |
52
|
|
|
return [ |
53
|
|
|
'DISTINCT' => '', |
54
|
|
|
'COL' => '', |
55
|
|
|
'TABLE' => 'FROM', |
56
|
|
|
'JOIN' => '', |
57
|
|
|
'WHERE' => 'WHERE', |
58
|
|
|
'GROUP' => 'GROUP BY', |
59
|
|
|
'HAVING' => 'HAVING', |
60
|
|
|
'ORDER' => 'ORDER BY', |
61
|
|
|
'LIMIT' => 'LIMIT', |
62
|
|
|
'UNION' => '', |
63
|
|
|
]; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* {@inheritDoc} |
68
|
|
|
*/ |
69
|
|
|
protected function getType()/*# : string */ |
70
|
|
|
{ |
71
|
|
|
return 'SELECT'; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.