1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MIT License |
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Phinx\Db\Adapter; |
9
|
|
|
|
10
|
|
|
use Phinx\Db\Table\Column; |
11
|
|
|
use Phinx\Db\Table\Table; |
12
|
|
|
use Phinx\Migration\MigrationInterface; |
13
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
14
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Adapter Wrapper. |
18
|
|
|
* |
19
|
|
|
* Proxy commands through to another adapter, allowing modification of |
20
|
|
|
* parameters during calls. |
21
|
|
|
* |
22
|
|
|
* @author Woody Gilk <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
abstract class AdapterWrapper implements AdapterInterface, WrapperInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var \Phinx\Db\Adapter\AdapterInterface |
28
|
|
|
*/ |
29
|
|
|
protected $adapter; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @inheritDoc |
33
|
|
|
*/ |
34
|
|
|
public function __construct(AdapterInterface $adapter) |
35
|
|
|
{ |
36
|
|
|
$this->setAdapter($adapter); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @inheritDoc |
41
|
|
|
*/ |
42
|
|
|
public function setAdapter(AdapterInterface $adapter) |
43
|
|
|
{ |
44
|
|
|
$this->adapter = $adapter; |
45
|
|
|
|
46
|
|
|
return $this; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @inheritDoc |
51
|
|
|
*/ |
52
|
|
|
public function getAdapter() |
53
|
|
|
{ |
54
|
|
|
return $this->adapter; |
55
|
|
|
} |
56
|
|
|
|
57
|
36 |
|
/** |
58
|
|
|
* @inheritDoc |
59
|
36 |
|
*/ |
60
|
36 |
|
public function setOptions(array $options) |
61
|
|
|
{ |
62
|
|
|
$this->adapter->setOptions($options); |
63
|
|
|
|
64
|
|
|
return $this; |
65
|
36 |
|
} |
66
|
|
|
|
67
|
36 |
|
/** |
68
|
36 |
|
* @inheritDoc |
69
|
|
|
*/ |
70
|
|
|
public function getOptions() |
71
|
|
|
{ |
72
|
|
|
return $this->adapter->getOptions(); |
73
|
|
|
} |
74
|
24 |
|
|
75
|
|
|
/** |
76
|
24 |
|
* @inheritDoc |
77
|
|
|
*/ |
78
|
|
|
public function hasOption($name) |
79
|
|
|
{ |
80
|
|
|
return $this->adapter->hasOption($name); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @inheritDoc |
85
|
|
|
*/ |
86
|
|
|
public function getOption($name) |
87
|
|
|
{ |
88
|
|
|
return $this->adapter->getOption($name); |
89
|
|
|
} |
90
|
|
|
|
91
|
2 |
|
/** |
92
|
|
|
* @inheritDoc |
93
|
2 |
|
*/ |
94
|
|
|
public function setInput(InputInterface $input) |
95
|
|
|
{ |
96
|
|
|
$this->adapter->setInput($input); |
97
|
|
|
|
98
|
|
|
return $this; |
99
|
8 |
|
} |
100
|
|
|
|
101
|
8 |
|
/** |
102
|
|
|
* @inheritDoc |
103
|
|
|
*/ |
104
|
|
|
public function getInput() |
105
|
|
|
{ |
106
|
|
|
return $this->adapter->getInput(); |
107
|
19 |
|
} |
108
|
|
|
|
109
|
19 |
|
/** |
110
|
|
|
* @inheritDoc |
111
|
|
|
*/ |
112
|
|
|
public function setOutput(OutputInterface $output) |
113
|
|
|
{ |
114
|
|
|
$this->adapter->setOutput($output); |
115
|
5 |
|
|
116
|
|
|
return $this; |
117
|
5 |
|
} |
118
|
5 |
|
|
119
|
|
|
/** |
120
|
|
|
* @inheritDoc |
121
|
|
|
*/ |
122
|
|
|
public function getOutput() |
123
|
|
|
{ |
124
|
|
|
return $this->adapter->getOutput(); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @inheritDoc |
129
|
|
|
*/ |
130
|
|
|
public function getColumnForType($columnName, $type, array $options) |
131
|
|
|
{ |
132
|
5 |
|
return $this->adapter->getColumnForType($columnName, $type, $options); |
133
|
|
|
} |
134
|
5 |
|
|
135
|
5 |
|
/** |
136
|
|
|
* @inheritDoc |
137
|
|
|
*/ |
138
|
|
|
public function connect() |
139
|
|
|
{ |
140
|
|
|
$this->getAdapter()->connect(); |
141
|
5 |
|
} |
142
|
|
|
|
143
|
5 |
|
/** |
144
|
|
|
* @inheritDoc |
145
|
|
|
*/ |
146
|
|
|
public function disconnect() |
147
|
|
|
{ |
148
|
|
|
$this->getAdapter()->disconnect(); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @inheritDoc |
153
|
|
|
*/ |
154
|
|
|
public function execute($sql) |
155
|
|
|
{ |
156
|
|
|
return $this->getAdapter()->execute($sql); |
157
|
5 |
|
} |
158
|
|
|
|
159
|
5 |
|
/** |
160
|
5 |
|
* @inheritDoc |
161
|
|
|
*/ |
162
|
|
|
public function query($sql) |
163
|
|
|
{ |
164
|
|
|
return $this->getAdapter()->query($sql); |
165
|
2 |
|
} |
166
|
|
|
|
167
|
2 |
|
/** |
168
|
|
|
* @inheritDoc |
169
|
|
|
*/ |
170
|
|
|
public function insert(Table $table, $row) |
171
|
|
|
{ |
172
|
|
|
$this->getAdapter()->insert($table, $row); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @inheritDoc |
177
|
|
|
*/ |
178
|
|
|
public function bulkinsert(Table $table, $rows) |
179
|
|
|
{ |
180
|
|
|
$this->getAdapter()->bulkinsert($table, $rows); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @inheritDoc |
185
|
|
|
*/ |
186
|
|
|
public function fetchRow($sql) |
187
|
|
|
{ |
188
|
|
|
return $this->getAdapter()->fetchRow($sql); |
189
|
3 |
|
} |
190
|
|
|
|
191
|
3 |
|
/** |
192
|
3 |
|
* @inheritDoc |
193
|
|
|
*/ |
194
|
|
|
public function fetchAll($sql) |
195
|
|
|
{ |
196
|
|
|
return $this->getAdapter()->fetchAll($sql); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @inheritDoc |
201
|
|
|
*/ |
202
|
|
|
public function getVersions() |
203
|
|
|
{ |
204
|
|
|
return $this->getAdapter()->getVersions(); |
205
|
1 |
|
} |
206
|
|
|
|
207
|
1 |
|
/** |
208
|
|
|
* @inheritDoc |
209
|
|
|
*/ |
210
|
|
|
public function getVersionLog() |
211
|
|
|
{ |
212
|
|
|
return $this->getAdapter()->getVersionLog(); |
213
|
5 |
|
} |
214
|
|
|
|
215
|
5 |
|
/** |
216
|
|
|
* @inheritDoc |
217
|
|
|
*/ |
218
|
|
|
public function migrated(MigrationInterface $migration, $direction, $startTime, $endTime) |
219
|
|
|
{ |
220
|
|
|
$this->getAdapter()->migrated($migration, $direction, $startTime, $endTime); |
221
|
5 |
|
|
222
|
|
|
return $this; |
223
|
5 |
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @inheritDoc |
227
|
|
|
*/ |
228
|
|
|
public function toggleBreakpoint(MigrationInterface $migration) |
229
|
5 |
|
{ |
230
|
|
|
$this->getAdapter()->toggleBreakpoint($migration); |
231
|
5 |
|
|
232
|
5 |
|
return $this; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @inheritDoc |
237
|
|
|
*/ |
238
|
1 |
|
public function resetAllBreakpoints() |
239
|
|
|
{ |
240
|
1 |
|
return $this->getAdapter()->resetAllBreakpoints(); |
241
|
1 |
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @inheritDoc |
245
|
|
|
*/ |
246
|
|
|
public function setBreakpoint(MigrationInterface $migration) |
247
|
1 |
|
{ |
248
|
|
|
$this->getAdapter()->setBreakpoint($migration); |
249
|
1 |
|
|
250
|
|
|
return $this; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* @inheritDoc |
255
|
|
|
*/ |
256
|
|
|
public function unsetBreakpoint(MigrationInterface $migration) |
257
|
|
|
{ |
258
|
|
|
$this->getAdapter()->unsetBreakpoint($migration); |
259
|
|
|
|
260
|
|
|
return $this; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* @inheritDoc |
265
|
|
|
*/ |
266
|
|
|
public function hasSchemaTable() |
267
|
|
|
{ |
268
|
|
|
return $this->getAdapter()->hasSchemaTable(); |
|
|
|
|
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* @inheritDoc |
273
|
|
|
*/ |
274
|
|
|
public function createSchemaTable() |
275
|
|
|
{ |
276
|
|
|
$this->getAdapter()->createSchemaTable(); |
277
|
|
|
} |
278
|
|
|
|
279
|
4 |
|
/** |
280
|
|
|
* @inheritDoc |
281
|
4 |
|
*/ |
282
|
|
|
public function getColumnTypes() |
283
|
|
|
{ |
284
|
|
|
return $this->getAdapter()->getColumnTypes(); |
285
|
|
|
} |
286
|
|
|
|
287
|
5 |
|
/** |
288
|
|
|
* @inheritDoc |
289
|
5 |
|
*/ |
290
|
|
|
public function isValidColumnType(Column $column) |
291
|
|
|
{ |
292
|
|
|
return $this->getAdapter()->isValidColumnType($column); |
293
|
|
|
} |
294
|
|
|
|
295
|
5 |
|
/** |
296
|
|
|
* @inheritDoc |
297
|
5 |
|
*/ |
298
|
5 |
|
public function hasTransactions() |
299
|
|
|
{ |
300
|
|
|
return $this->getAdapter()->hasTransactions(); |
301
|
|
|
} |
302
|
|
|
|
303
|
5 |
|
/** |
304
|
|
|
* @inheritDoc |
305
|
5 |
|
*/ |
306
|
5 |
|
public function beginTransaction() |
307
|
|
|
{ |
308
|
|
|
$this->getAdapter()->beginTransaction(); |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* @inheritDoc |
313
|
|
|
*/ |
314
|
|
|
public function commitTransaction() |
315
|
|
|
{ |
316
|
|
|
$this->getAdapter()->commitTransaction(); |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
/** |
320
|
|
|
* @inheritDoc |
321
|
|
|
*/ |
322
|
|
|
public function rollbackTransaction() |
323
|
|
|
{ |
324
|
|
|
$this->getAdapter()->rollbackTransaction(); |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* @inheritDoc |
329
|
|
|
*/ |
330
|
|
|
public function quoteTableName($tableName) |
331
|
|
|
{ |
332
|
|
|
return $this->getAdapter()->quoteTableName($tableName); |
333
|
|
|
} |
334
|
|
|
|
335
|
5 |
|
/** |
336
|
|
|
* @inheritDoc |
337
|
5 |
|
*/ |
338
|
|
|
public function quoteColumnName($columnName) |
339
|
|
|
{ |
340
|
|
|
return $this->getAdapter()->quoteColumnName($columnName); |
341
|
|
|
} |
342
|
|
|
|
343
|
6 |
|
/** |
344
|
|
|
* @inheritDoc |
345
|
6 |
|
*/ |
346
|
6 |
|
public function hasTable($tableName) |
347
|
|
|
{ |
348
|
|
|
return $this->getAdapter()->hasTable($tableName); |
349
|
|
|
} |
350
|
|
|
|
351
|
4 |
|
/** |
352
|
|
|
* @inheritDoc |
353
|
4 |
|
*/ |
354
|
4 |
|
public function createTable(Table $table, array $columns = [], array $indexes = []) |
355
|
|
|
{ |
356
|
|
|
$this->getAdapter()->createTable($table, $columns, $indexes); |
357
|
|
|
} |
358
|
|
|
|
359
|
4 |
|
/** |
360
|
|
|
* @inheritDoc |
361
|
4 |
|
*/ |
362
|
4 |
|
public function getColumns($tableName) |
363
|
|
|
{ |
364
|
|
|
return $this->getAdapter()->getColumns($tableName); |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* @inheritDoc |
369
|
|
|
*/ |
370
|
|
|
public function hasColumn($tableName, $columnName) |
371
|
|
|
{ |
372
|
|
|
return $this->getAdapter()->hasColumn($tableName, $columnName); |
373
|
|
|
} |
374
|
|
|
|
375
|
1 |
|
/** |
376
|
|
|
* @inheritDoc |
377
|
1 |
|
*/ |
378
|
|
|
public function hasIndex($tableName, $columns) |
379
|
|
|
{ |
380
|
|
|
return $this->getAdapter()->hasIndex($tableName, $columns); |
381
|
|
|
} |
382
|
|
|
|
383
|
4 |
|
/** |
384
|
|
|
* @inheritDoc |
385
|
4 |
|
*/ |
386
|
|
|
public function hasIndexByName($tableName, $indexName) |
387
|
|
|
{ |
388
|
|
|
return $this->getAdapter()->hasIndexByName($tableName, $indexName); |
389
|
|
|
} |
390
|
|
|
|
391
|
4 |
|
/** |
392
|
|
|
* @inheritDoc |
393
|
4 |
|
*/ |
394
|
4 |
|
public function hasPrimaryKey($tableName, $columns, $constraint = null) |
395
|
|
|
{ |
396
|
|
|
return $this->getAdapter()->hasPrimaryKey($tableName, $columns, $constraint); |
397
|
|
|
} |
398
|
|
|
|
399
|
4 |
|
/** |
400
|
|
|
* @inheritDoc |
401
|
4 |
|
*/ |
402
|
4 |
|
public function hasForeignKey($tableName, $columns, $constraint = null) |
403
|
|
|
{ |
404
|
|
|
return $this->getAdapter()->hasForeignKey($tableName, $columns, $constraint); |
405
|
|
|
} |
406
|
|
|
|
407
|
1 |
|
/** |
408
|
|
|
* @inheritDoc |
409
|
1 |
|
*/ |
410
|
|
|
public function getSqlType($type, $limit = null) |
411
|
|
|
{ |
412
|
|
|
return $this->getAdapter()->getSqlType($type, $limit); |
413
|
|
|
} |
414
|
|
|
|
415
|
4 |
|
/** |
416
|
|
|
* @inheritDoc |
417
|
4 |
|
*/ |
418
|
4 |
|
public function createDatabase($name, $options = []) |
419
|
|
|
{ |
420
|
|
|
$this->getAdapter()->createDatabase($name, $options); |
421
|
|
|
} |
422
|
|
|
|
423
|
1 |
|
/** |
424
|
|
|
* @inheritDoc |
425
|
1 |
|
*/ |
426
|
|
|
public function hasDatabase($name) |
427
|
|
|
{ |
428
|
|
|
return $this->getAdapter()->hasDatabase($name); |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
/** |
432
|
|
|
* @inheritDoc |
433
|
|
|
*/ |
434
|
|
|
public function dropDatabase($name) |
435
|
|
|
{ |
436
|
|
|
$this->getAdapter()->dropDatabase($name); |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
/** |
440
|
|
|
* @inheritDoc |
441
|
|
|
*/ |
442
|
|
|
public function createSchema($schemaName = 'public') |
443
|
|
|
{ |
444
|
|
|
$this->getAdapter()->createSchema($schemaName); |
445
|
|
|
} |
446
|
|
|
|
447
|
1 |
|
/** |
448
|
|
|
* @inheritDoc |
449
|
1 |
|
*/ |
450
|
1 |
|
public function dropSchema($schemaName) |
451
|
|
|
{ |
452
|
|
|
$this->getAdapter()->dropSchema($schemaName); |
453
|
|
|
} |
454
|
|
|
|
455
|
1 |
|
/** |
456
|
|
|
* @inheritDoc |
457
|
1 |
|
*/ |
458
|
1 |
|
public function truncateTable($tableName) |
459
|
|
|
{ |
460
|
|
|
$this->getAdapter()->truncateTable($tableName); |
461
|
|
|
} |
462
|
|
|
|
463
|
4 |
|
/** |
464
|
|
|
* @inheritDoc |
465
|
4 |
|
*/ |
466
|
|
|
public function castToBool($value) |
467
|
|
|
{ |
468
|
|
|
return $this->getAdapter()->castToBool($value); |
469
|
|
|
} |
470
|
|
|
|
471
|
4 |
|
/** |
472
|
|
|
* @return \PDO |
473
|
4 |
|
*/ |
474
|
4 |
|
public function getConnection() |
475
|
|
|
{ |
476
|
|
|
return $this->getAdapter()->getConnection(); |
|
|
|
|
477
|
|
|
} |
478
|
|
|
|
479
|
4 |
|
/** |
480
|
|
|
* @inheritDoc |
481
|
4 |
|
*/ |
482
|
4 |
|
public function executeActions(Table $table, array $actions) |
483
|
|
|
{ |
484
|
|
|
$this->getAdapter()->executeActions($table, $actions); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* @inheritDoc |
489
|
|
|
*/ |
490
|
|
|
public function getQueryBuilder() |
491
|
|
|
{ |
492
|
|
|
return $this->getAdapter()->getQueryBuilder(); |
493
|
|
|
} |
494
|
|
|
} |
495
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.