1 | <?php declare(strict_types=1); |
||
24 | abstract class AbstractUtil { |
||
25 | |||
26 | /** |
||
27 | * Reference to the current connection object |
||
28 | * @var DriverInterface |
||
29 | */ |
||
30 | private $conn; |
||
31 | |||
32 | /** |
||
33 | * Save a reference to the connection object for later use |
||
34 | * |
||
35 | * @param DriverInterface $conn |
||
36 | */ |
||
37 | public function __construct(DriverInterface $conn) |
||
41 | |||
42 | /** |
||
43 | * Get the driver object for the current connection |
||
44 | * |
||
45 | * @return DriverInterface |
||
46 | */ |
||
47 | public function getDriver() |
||
51 | |||
52 | /** |
||
53 | * Convenience public function to generate sql for creating a db table |
||
54 | * |
||
55 | * @param string $name |
||
56 | * @param array $fields |
||
57 | * @param array $constraints |
||
58 | * @param bool $ifNotExists |
||
59 | * @return string |
||
60 | */ |
||
61 | public function createTable($name, $fields, array $constraints=[], $ifNotExists=TRUE) |
||
94 | |||
95 | /** |
||
96 | * Drop the selected table |
||
97 | * |
||
98 | * @param string $name |
||
99 | * @return string |
||
100 | */ |
||
101 | public function deleteTable($name) |
||
105 | |||
106 | // -------------------------------------------------------------------------- |
||
107 | // ! Abstract Methods |
||
108 | // -------------------------------------------------------------------------- |
||
109 | |||
110 | /** |
||
111 | * Return an SQL file with the database table structure |
||
112 | * |
||
113 | * @abstract |
||
114 | * @return string |
||
115 | */ |
||
116 | abstract public function backupStructure(); |
||
117 | |||
118 | /** |
||
119 | * Return an SQL file with the database data as insert statements |
||
120 | * |
||
121 | * @abstract |
||
122 | * @return string |
||
123 | */ |
||
124 | abstract public function backupData(); |
||
125 | |||
126 | } |