1 | <?php |
||
32 | abstract class StatementAbstract extends ObjectAbstract implements StatementInterface |
||
33 | { |
||
34 | use SettingsAwareTrait, BuilderAwareTrait, ExtraClauseTrait, PreviousTrait; |
||
35 | |||
36 | /** |
||
37 | * value bindings |
||
38 | * |
||
39 | * @var array |
||
40 | * @access protected |
||
41 | */ |
||
42 | protected $bindings; |
||
43 | |||
44 | /** |
||
45 | * clause configs,[name => prefix] |
||
46 | * |
||
47 | * @var array |
||
48 | * @access protected |
||
49 | */ |
||
50 | protected $configs = []; |
||
51 | |||
52 | /** |
||
53 | * Constructor |
||
54 | * |
||
55 | * @param BuilderInterface $builder |
||
56 | * @access public |
||
57 | */ |
||
58 | public function __construct(BuilderInterface $builder) |
||
62 | |||
63 | /** |
||
64 | * {@inheritDoc} |
||
65 | */ |
||
66 | public function getStatement(array $settings = [])/*# : string */ |
||
77 | |||
78 | /** |
||
79 | * {@inheritDoc} |
||
80 | */ |
||
81 | public function getNamedStatement(array $settings = [])/*# : string */ |
||
87 | |||
88 | /** |
||
89 | * Return the sql string (with parameter replaced) |
||
90 | * |
||
91 | * @param array $settings extra settings if any |
||
92 | * @return string |
||
93 | * @access public |
||
94 | * @api |
||
95 | */ |
||
96 | public function getSql(array $settings = [])/*# : string */ |
||
102 | |||
103 | /** |
||
104 | * {@inheritDoc} |
||
105 | */ |
||
106 | public function getBindings()/*# : array */ |
||
110 | |||
111 | /** |
||
112 | * {@inheritDoc} |
||
113 | */ |
||
114 | public function __toString()/*# : string */ |
||
118 | |||
119 | /** |
||
120 | * Combine builder/statement and provided settings |
||
121 | * |
||
122 | * @param array $settings statement specific settings |
||
123 | * @return array |
||
124 | * @access protected |
||
125 | */ |
||
126 | protected function combineSettings(array $settings)/*# : array */ |
||
135 | |||
136 | /** |
||
137 | * Build SQL statement clauses |
||
138 | * |
||
139 | * @param array $settings |
||
140 | * @param string |
||
141 | * @access protected |
||
142 | */ |
||
143 | protected function buildSql(array $settings)/*# : string */ |
||
163 | |||
164 | /** |
||
165 | * Replace placeholders in the sql with '?', ':named' or real value |
||
166 | * |
||
167 | * @param string $sql |
||
168 | * @param array $settings |
||
169 | * @return string |
||
170 | * @access protected |
||
171 | */ |
||
172 | protected function bindValues(/*# string */ $sql, array $settings)/*# : string */ |
||
181 | |||
182 | /** |
||
183 | * Clause configs ['name' => 'prefix'] |
||
184 | * |
||
185 | * @return array |
||
186 | * @access protected |
||
187 | */ |
||
188 | abstract protected function getConfigs()/*# : array */; |
||
189 | |||
190 | /** |
||
191 | * Get current statement type. e.g. 'SELECT' etc. |
||
192 | * |
||
193 | * @return string |
||
194 | * @access protected |
||
195 | */ |
||
196 | abstract protected function getType()/*# : string */; |
||
197 | } |
||
198 |