1 | <?php |
||
28 | class Pdo implements StorageInterface |
||
29 | { |
||
30 | use DataTypeCasterTrait; |
||
31 | |||
32 | /** |
||
33 | * @var PhpPdo |
||
34 | */ |
||
35 | protected $conn; |
||
36 | |||
37 | /** |
||
38 | * @var PdoConfig |
||
39 | */ |
||
40 | protected $config; |
||
41 | |||
42 | /** |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $quoteMaps = array('mysql' => '`', 'pgsql' => '"'); |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $quote = '`'; |
||
51 | |||
52 | /** |
||
53 | * Constructor. |
||
54 | * |
||
55 | * @param PdoConfig $config |
||
56 | */ |
||
57 | public function __construct(PdoConfig $config) |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | public function save(ReadModelInterface $model, $table) |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function remove($id, $table) |
||
101 | |||
102 | /** |
||
103 | * {@inheritdoc} |
||
104 | */ |
||
105 | public function findById($id, $table, $class) |
||
111 | |||
112 | /** |
||
113 | * {@inheritdoc} |
||
114 | */ |
||
115 | public function finder($table, $class) |
||
119 | |||
120 | /** |
||
121 | * Execute query without statement. |
||
122 | * |
||
123 | * @param string $sql |
||
124 | * @param array $values |
||
125 | */ |
||
126 | public function exec($sql, array $values = array()) |
||
144 | |||
145 | /** |
||
146 | * Execute query with statement. |
||
147 | * |
||
148 | * @param string $sql |
||
149 | * @param int $mode |
||
150 | * |
||
151 | * @return PDOStatement |
||
152 | */ |
||
153 | public function query($sql, $mode = PhpPdo::FETCH_ASSOC) |
||
161 | |||
162 | /** |
||
163 | * Compute fields to expressions. |
||
164 | * |
||
165 | * @param array $fields |
||
166 | * @param PdoFinder $finder |
||
167 | * |
||
168 | * @return PdoCompositeExpression |
||
169 | */ |
||
170 | protected function computeFieldsExpression(array $fields, PdoFinder $finder) |
||
179 | |||
180 | /** |
||
181 | * Normalize value. |
||
182 | * |
||
183 | * @param array $values |
||
184 | * |
||
185 | * @return array |
||
186 | */ |
||
187 | protected function normalize(array $values) |
||
206 | |||
207 | /** |
||
208 | * Build query update. |
||
209 | * |
||
210 | * @param array $values |
||
211 | * @param array $conditions |
||
212 | * @param string $table |
||
213 | * |
||
214 | * @return string |
||
215 | */ |
||
216 | protected function buildUpdateQuery(array $values, array $conditions, $table) |
||
226 | |||
227 | /** |
||
228 | * Build insert query. |
||
229 | * |
||
230 | * @param array $values |
||
231 | * @param string $table |
||
232 | * |
||
233 | * @return string |
||
234 | */ |
||
235 | public function buildInsertQuery(array $values, $table) |
||
244 | |||
245 | /** |
||
246 | * Build data sets. |
||
247 | * |
||
248 | * @param array $parts |
||
249 | * |
||
250 | * @return array |
||
251 | */ |
||
252 | protected function buildDataSets(array $parts) |
||
261 | |||
262 | /** |
||
263 | * Quote field. |
||
264 | * |
||
265 | * @param string $field |
||
266 | * |
||
267 | * @return string |
||
268 | */ |
||
269 | protected function quote($field) |
||
273 | } |
||
274 |