1 | <?php |
||
24 | abstract class QueryBuilder extends Component implements ExpressionInterface |
||
25 | { |
||
26 | /** |
||
27 | * @var Driver |
||
28 | */ |
||
29 | protected $driver = null; |
||
30 | |||
31 | /** |
||
32 | * @var QueryCompiler |
||
33 | */ |
||
34 | protected $compiler = null; |
||
35 | |||
36 | /** |
||
37 | * @param Driver $driver Associated driver. |
||
38 | * @param QueryCompiler $compiler Driver specific QueryCompiler instance (one per builder). |
||
39 | */ |
||
40 | public function __construct(Driver $driver, QueryCompiler $compiler) |
||
45 | |||
46 | /** |
||
47 | * Get associated driver instance. |
||
48 | * |
||
49 | * @return Driver |
||
50 | */ |
||
51 | public function getDriver(): Driver |
||
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | * |
||
59 | * @param QueryCompiler $compiler Associated compiled to be used by default. |
||
60 | */ |
||
61 | abstract public function sqlStatement(QueryCompiler $compiler = null): string; |
||
62 | |||
63 | /** |
||
64 | * Get ordered list of builder parameters in a form of ParameterInterface array. |
||
65 | * |
||
66 | * @return ParameterInterface[] |
||
67 | * |
||
68 | * @throws BuilderException |
||
69 | */ |
||
70 | abstract public function getParameters(): array; |
||
71 | |||
72 | /** |
||
73 | * Get interpolated (populated with parameters) SQL which will be run against database, please |
||
74 | * use this method for debugging purposes only. |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | public function queryString(): string |
||
82 | |||
83 | /** |
||
84 | * @return string |
||
85 | */ |
||
86 | public function __toString(): string |
||
90 | |||
91 | /** |
||
92 | * @return array |
||
93 | */ |
||
94 | public function __debugInfo() |
||
110 | |||
111 | /** |
||
112 | * Helper methods used to correctly fetch and split identifiers provided by function |
||
113 | * parameters. |
||
114 | * It support array list, string or comma separated list. Attention, this method will not work |
||
115 | * with complex parameters (such as functions) provided as one comma separated string, please |
||
116 | * use arrays in this case. |
||
117 | * |
||
118 | * @param array $identifiers |
||
119 | * |
||
120 | * @return array |
||
121 | */ |
||
122 | protected function fetchIdentifiers(array $identifiers): array |
||
134 | |||
135 | /** |
||
136 | * Expand all QueryBuilder parameters to create flatten list. |
||
137 | * |
||
138 | * @param array $parameters |
||
139 | * |
||
140 | * @return array |
||
141 | */ |
||
142 | protected function flattenParameters(array $parameters): array |
||
156 | |||
157 | /** |
||
158 | * Generate PDO statement based on generated sql and parameters. |
||
159 | * |
||
160 | * @return \PDOStatement |
||
161 | */ |
||
162 | protected function pdoStatement(): \PDOStatement |
||
166 | |||
167 | /** |
||
168 | * @return ContainerInterface |
||
169 | */ |
||
170 | protected function iocContainer() |
||
175 | } |
||
176 |