1 | <?php |
||
31 | abstract class AbstractUtil { |
||
32 | |||
33 | /** |
||
34 | * Reference to the current connection object |
||
35 | * @var DriverInterface |
||
36 | */ |
||
37 | private $conn; |
||
38 | |||
39 | /** |
||
40 | * Save a reference to the connection object for later use |
||
41 | * |
||
42 | * @param DriverInterface $conn |
||
43 | */ |
||
44 | public function __construct(DriverInterface $conn) |
||
48 | |||
49 | // -------------------------------------------------------------------------- |
||
50 | |||
51 | /** |
||
52 | * Get the driver object for the current connection |
||
53 | * |
||
54 | * @return Driver_Interface |
||
55 | */ |
||
56 | public function get_driver() |
||
60 | |||
61 | // -------------------------------------------------------------------------- |
||
62 | |||
63 | /** |
||
64 | * Convenience public function to generate sql for creating a db table |
||
65 | * |
||
66 | * @param string $name |
||
67 | * @param array $fields |
||
68 | * @param array $constraints |
||
69 | * @param bool $if_not_exists |
||
70 | * @return string |
||
71 | */ |
||
72 | public function create_table($name, $fields, array $constraints=[], $if_not_exists=TRUE) |
||
105 | |||
106 | // -------------------------------------------------------------------------- |
||
107 | |||
108 | /** |
||
109 | * Drop the selected table |
||
110 | * |
||
111 | * @param string $name |
||
112 | * @return string |
||
113 | */ |
||
114 | public function delete_table($name) |
||
118 | |||
119 | |||
120 | // -------------------------------------------------------------------------- |
||
121 | // ! Abstract Methods |
||
122 | // -------------------------------------------------------------------------- |
||
123 | |||
124 | /** |
||
125 | * Return an SQL file with the database table structure |
||
126 | * |
||
127 | * @abstract |
||
128 | * @return string |
||
129 | */ |
||
130 | abstract public function backup_structure(); |
||
131 | |||
132 | // -------------------------------------------------------------------------- |
||
133 | |||
134 | /** |
||
135 | * Return an SQL file with the database data as insert statements |
||
136 | * |
||
137 | * @abstract |
||
138 | * @return string |
||
139 | */ |
||
140 | abstract public function backup_data(); |
||
141 | |||
142 | } |
||
143 | // End of abstract_util.php |