1 | <?php |
||
28 | abstract class AbstractUtil { |
||
29 | |||
30 | /** |
||
31 | * Reference to the current connection object |
||
32 | */ |
||
33 | private $conn; |
||
34 | |||
35 | /** |
||
36 | * Save a reference to the connection object for later use |
||
37 | * |
||
38 | * @param DriverInterface $conn |
||
39 | */ |
||
40 | public function __construct(DriverInterface $conn) |
||
44 | |||
45 | // -------------------------------------------------------------------------- |
||
46 | |||
47 | /** |
||
48 | * Get the driver object for the current connection |
||
49 | * |
||
50 | * @return Driver_Interface |
||
51 | */ |
||
52 | public function get_driver() |
||
56 | |||
57 | // -------------------------------------------------------------------------- |
||
58 | |||
59 | /** |
||
60 | * Convenience public function to generate sql for creating a db table |
||
61 | * |
||
62 | * @param string $name |
||
63 | * @param array $fields |
||
64 | * @param array $constraints |
||
65 | * @param bool $if_not_exists |
||
66 | * @return string |
||
67 | */ |
||
68 | public function create_table($name, $fields, array $constraints=array(), $if_not_exists=TRUE) |
||
101 | |||
102 | // -------------------------------------------------------------------------- |
||
103 | |||
104 | /** |
||
105 | * Drop the selected table |
||
106 | * |
||
107 | * @param string $name |
||
108 | * @return string |
||
109 | */ |
||
110 | public function delete_table($name) |
||
114 | |||
115 | |||
116 | // -------------------------------------------------------------------------- |
||
117 | // ! Abstract Methods |
||
118 | // -------------------------------------------------------------------------- |
||
119 | |||
120 | /** |
||
121 | * Return an SQL file with the database table structure |
||
122 | * |
||
123 | * @abstract |
||
124 | * @return string |
||
125 | */ |
||
126 | abstract public function backup_structure(); |
||
127 | |||
128 | // -------------------------------------------------------------------------- |
||
129 | |||
130 | /** |
||
131 | * Return an SQL file with the database data as insert statements |
||
132 | * |
||
133 | * @abstract |
||
134 | * @return string |
||
135 | */ |
||
136 | abstract public function backup_data(); |
||
137 | |||
138 | } |
||
139 | // End of abstract_util.php |