|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace BfwSql\Queries\Parts; |
|
4
|
|
|
|
|
5
|
|
|
use \BfwSql\Queries\AbstractQuery; |
|
6
|
|
|
|
|
7
|
|
|
abstract class AbstractPart implements PartInterface |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @var \BfwSql\Queries\AbstractQuery $querySystem The object who generate |
|
11
|
|
|
* the full query |
|
12
|
|
|
*/ |
|
13
|
|
|
protected $querySystem; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @var string $tablePrefix The prefix to use which all table into the base |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $tablePrefix = ''; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var string $partPrefix The prefix to use before this query part |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $partPrefix = ''; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var boolean $usePartPrefix If the part don't have prefix |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $usePartPrefix = true; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var boolean $canBeEmpty If the query part generated can be empty |
|
32
|
|
|
* Example : The FROM part can not be empty for a SELECT query |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $canBeEmpty = true; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Define querySystem property and find the tablePrefix |
|
38
|
|
|
* |
|
39
|
|
|
* @param \BfwSql\Queries\AbstractQuery $querySystem |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct(AbstractQuery $querySystem) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->querySystem = $querySystem; |
|
44
|
|
|
$this->tablePrefix = $querySystem |
|
45
|
|
|
->getSqlConnect() |
|
46
|
|
|
->getConnectionInfos() |
|
47
|
|
|
->tablePrefix |
|
48
|
|
|
; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Getter accessor to property querySystem |
|
53
|
|
|
* |
|
54
|
|
|
* @return \BfwSql\Queries\AbstractQuery |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getQuerySystem(): AbstractQuery |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->querySystem; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Getter accessor to property tablePrefix |
|
63
|
|
|
* |
|
64
|
|
|
* @return string |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getTablePrefix(): string |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->tablePrefix; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Getter accessor to property partPrefix |
|
73
|
|
|
* |
|
74
|
|
|
* @return string |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getPartPrefix(): string |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->partPrefix; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Getter accessor to property usePartPrefix |
|
83
|
|
|
* |
|
84
|
|
|
* @return bool |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getUsePartPrefix(): bool |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->usePartPrefix; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Getter accessor to property canBeEmpty |
|
93
|
|
|
* |
|
94
|
|
|
* @return bool |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getCanBeEmpty(): bool |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->canBeEmpty; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|