1 | <?php |
||
11 | class SQLDumper |
||
12 | { |
||
13 | /** |
||
14 | * @var string Host for the DB connection |
||
15 | */ |
||
16 | protected $host = ''; |
||
17 | |||
18 | /** |
||
19 | * @var string Name of the DB |
||
20 | */ |
||
21 | protected $dbname = ''; |
||
22 | |||
23 | /** |
||
24 | * @var string Username used for the DB connection |
||
25 | */ |
||
26 | protected $username = ''; |
||
27 | |||
28 | /** |
||
29 | * @var string Password used for the DB connection |
||
30 | */ |
||
31 | protected $password = ''; |
||
32 | |||
33 | /** |
||
34 | * @var PDO PDO instance of the DB |
||
35 | */ |
||
36 | protected $db = NULL; |
||
37 | |||
38 | /** |
||
39 | * @var TableDumperCollection Contains all TableDumper objects that will be used for this dump |
||
40 | */ |
||
41 | protected $listTableDumpers; |
||
42 | |||
43 | |||
44 | /** |
||
45 | * @param string Host for the DB connection |
||
46 | * @param string Name of the DB |
||
47 | * @param string Username used for the DB connection |
||
48 | * @param string Password used for the DB connection |
||
49 | */ |
||
50 | 39 | public function __construct($host, $dbname, $username, $password = '') |
|
61 | |||
62 | /** |
||
63 | * Connects to the SQL database |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | 39 | protected function connect() |
|
77 | |||
78 | /** |
||
79 | * Get the main list of TableDumper |
||
80 | * |
||
81 | * @return TableDumperCollection Returns the list of table dumpers as TableDumperCollection |
||
82 | */ |
||
83 | 3 | public function getListTableDumpers() |
|
87 | |||
88 | /** |
||
89 | * Set a TableDumper for the given table in order to specify certain dump options on it |
||
90 | * |
||
91 | * @param Table|string The table to set |
||
92 | * |
||
93 | * @return TableDumper Returns a TableDumper |
||
94 | */ |
||
95 | 27 | public function table($table) |
|
99 | |||
100 | /** |
||
101 | * Set a TableDumperCollection for the given list of tables in order to specify certain dump options on them |
||
102 | * |
||
103 | * @param TableDumperCollection|array<TableDumper|Table|string> The list of tables to set (either as a TableDumperCollection, or an array containing either TableDumper objects, Table objects or table names) |
||
104 | * |
||
105 | * @return TableDumperCollection Returns a TableDumperCollection |
||
106 | */ |
||
107 | 9 | public function listTables($listTables) |
|
111 | |||
112 | /** |
||
113 | * Set a TableDumperCollection for all the tables in the database, in order to specify certain dump options on them |
||
114 | * |
||
115 | * @return TableDumperCollection Returns a TableDumperCollection |
||
116 | */ |
||
117 | 3 | public function allTables() |
|
132 | |||
133 | /** |
||
134 | * Writes the complete dump of the database to the given stream |
||
135 | * |
||
136 | * @param resource Stream to write to |
||
137 | * |
||
138 | * @return void |
||
139 | */ |
||
140 | 21 | public function dump($stream) |
|
151 | |||
152 | /** |
||
153 | * Creates and saves the dump to a file |
||
154 | * |
||
155 | * @param string File name for the dump |
||
156 | * |
||
157 | * @return void |
||
158 | */ |
||
159 | 3 | public function save($filename) |
|
165 | } |