1 | <?php |
||
6 | abstract class DbExporter |
||
7 | { |
||
8 | /** |
||
9 | * Contains the ignore tables |
||
10 | * @var array $ignore |
||
11 | */ |
||
12 | public static $ignore = array('migrations'); |
||
13 | public static $remote; |
||
14 | |||
15 | /** |
||
16 | * Get all the tables |
||
17 | * @return mixed |
||
18 | */ |
||
19 | public $database; |
||
20 | |||
21 | /** |
||
22 | * Select fields |
||
23 | * |
||
24 | * @var array $selects |
||
25 | **/ |
||
26 | protected $selects = array( |
||
27 | 'column_name as Field', |
||
28 | 'column_type as Type', |
||
29 | 'is_nullable as Null', |
||
30 | 'column_key as Key', |
||
31 | 'column_default as Default', |
||
32 | 'extra as Extra', |
||
33 | 'data_type as Data_Type' |
||
34 | ); |
||
35 | /** |
||
36 | * Select fields from constraints |
||
37 | * |
||
38 | * @var array $constraints |
||
39 | **/ |
||
40 | protected $constraints = array( |
||
41 | 'key_column_usage.table_name as Table', |
||
42 | 'key_column_usage.column_name as Field', |
||
43 | 'key_column_usage.referenced_table_name as ON', |
||
44 | 'key_column_usage.referenced_column_name as References', |
||
45 | 'REFERENTIAL_CONSTRAINTS.UPDATE_RULE as onUpdate', |
||
46 | 'REFERENTIAL_CONSTRAINTS.DELETE_RULE as onDelete', |
||
47 | ); |
||
48 | protected function getTables() |
||
53 | |||
54 | public function getTableIndexes($table) |
||
59 | |||
60 | /** |
||
61 | * Get all the columns for a given table |
||
62 | * @param $table |
||
63 | * @return mixed |
||
64 | */ |
||
65 | protected function getTableDescribes($table) |
||
72 | |||
73 | /** |
||
74 | * Get all the foreign key constraints for a given table |
||
75 | * @param $table |
||
76 | * @return mixed |
||
77 | */ |
||
78 | protected function getTableConstraints($table) |
||
87 | |||
88 | /** |
||
89 | * Grab all the table data |
||
90 | * @param $table |
||
91 | * @return mixed |
||
92 | */ |
||
93 | protected function getTableData($table) |
||
97 | /** |
||
98 | * Try to create directories if they dont exist |
||
99 | * |
||
100 | * @return void |
||
101 | * @param string $path |
||
102 | **/ |
||
103 | protected function makePath($path) |
||
115 | |||
116 | /** |
||
117 | * Write the file |
||
118 | * @return mixed |
||
119 | */ |
||
120 | abstract public function write(); |
||
121 | |||
122 | /** |
||
123 | * Convert the database to a usefull format |
||
124 | * @param null $database |
||
125 | * @return mixed |
||
126 | */ |
||
127 | abstract public function convert($database = null); |
||
128 | |||
129 | /** |
||
130 | * Put the converted stub into a template |
||
131 | * @return mixed |
||
132 | */ |
||
133 | abstract protected function compile(); |
||
134 | } |
If you suppress an error, we recommend checking for the error condition explicitly: