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