1 | <?php |
||
19 | class Mysqldump extends Abstraction implements Executable |
||
20 | { |
||
21 | /** |
||
22 | * Host to connect to |
||
23 | * --host <hostname> |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | private $host; |
||
28 | |||
29 | /** |
||
30 | * User to connect with |
||
31 | * --user <username> |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | private $user; |
||
36 | |||
37 | /** |
||
38 | * Password to authenticate with |
||
39 | * --password <password> |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | private $password; |
||
44 | |||
45 | /** |
||
46 | * List of tables to backup |
||
47 | * --tables array of strings |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | private $tablesToDump = array(); |
||
52 | |||
53 | /** |
||
54 | * List of databases to backup |
||
55 | * --databases array of strings |
||
56 | * |
||
57 | * @var array |
||
58 | */ |
||
59 | private $databasesToDump = array(); |
||
60 | |||
61 | /** |
||
62 | * List of tables to ignore |
||
63 | * |
||
64 | * @var array |
||
65 | */ |
||
66 | private $tablesToIgnore = array(); |
||
67 | |||
68 | /** |
||
69 | * List of tables where only the table structure is stored |
||
70 | * |
||
71 | * @var array |
||
72 | */ |
||
73 | private $structureOnly = array(); |
||
74 | |||
75 | /** |
||
76 | * Use mysqldump quick mode |
||
77 | * -q |
||
78 | * |
||
79 | * @var bool |
||
80 | */ |
||
81 | private $quick = false; |
||
82 | |||
83 | /** |
||
84 | * |
||
85 | * Lock tables option |
||
86 | * --lock-tables |
||
87 | * |
||
88 | * @var bool |
||
89 | */ |
||
90 | private $lockTables; |
||
91 | |||
92 | /** |
||
93 | * Use mysqldump with compression |
||
94 | * -C |
||
95 | * |
||
96 | * @var bool |
||
97 | */ |
||
98 | private $compress = false; |
||
99 | |||
100 | /** |
||
101 | * Dump only table structures |
||
102 | * --no-data |
||
103 | * |
||
104 | * @var boolean |
||
105 | */ |
||
106 | private $noData = false; |
||
107 | |||
108 | /** |
||
109 | * Use mysqldump extended insert mode |
||
110 | * -e, --extended-insert |
||
111 | * |
||
112 | * @var boolean |
||
113 | */ |
||
114 | private $extendedInsert = false; |
||
115 | |||
116 | /** |
||
117 | * Dump blob fields as hex. |
||
118 | * --hex-blob |
||
119 | * |
||
120 | * @var boolean |
||
121 | */ |
||
122 | private $hexBlob = false; |
||
123 | |||
124 | /** |
||
125 | * Path to dump file |
||
126 | * |
||
127 | 14 | * @var string |
|
128 | */ |
||
129 | 14 | private $dumpPathname; |
|
130 | 14 | ||
131 | 14 | /** |
|
132 | * Constructor. |
||
133 | * |
||
134 | * @param string $path |
||
135 | */ |
||
136 | public function __construct($path = null) |
||
141 | |||
142 | 3 | /** |
|
143 | 3 | * Set the mysql credentials. |
|
144 | 3 | * |
|
145 | * @param string $user |
||
146 | * @param string $password |
||
147 | * @return \phpbu\App\Cli\Executable\Mysqldump |
||
148 | */ |
||
149 | public function credentials($user = null, $password = null) |
||
155 | 3 | ||
156 | 3 | /** |
|
157 | * Set the mysql hostname. |
||
158 | * |
||
159 | * @param string $host |
||
160 | * @return \phpbu\App\Cli\Executable\Mysqldump |
||
161 | */ |
||
162 | public function useHost($host) |
||
167 | 3 | ||
168 | 3 | /** |
|
169 | * Use '-q' quick mode. |
||
170 | * |
||
171 | * @param boolean $bool |
||
172 | * @return \phpbu\App\Cli\Executable\Mysqldump |
||
173 | */ |
||
174 | public function useQuickMode($bool) |
||
179 | 3 | ||
180 | 3 | /** |
|
181 | * Use '--lock-tables' option. |
||
182 | * |
||
183 | * @param boolean $bool |
||
184 | * @return \phpbu\App\Cli\Executable\Mysqldump |
||
185 | */ |
||
186 | public function lockTables($bool) |
||
191 | 4 | ||
192 | 4 | /** |
|
193 | * Use '-C' compress mode. |
||
194 | * |
||
195 | * @param boolean $bool |
||
196 | * @return \phpbu\App\Cli\Executable\Mysqldump |
||
197 | */ |
||
198 | public function useCompression($bool) |
||
203 | 4 | ||
204 | 4 | /** |
|
205 | * Use '-e' extended insert mode. |
||
206 | * |
||
207 | * @param boolean $bool |
||
208 | * @return \phpbu\App\Cli\Executable\Mysqldump |
||
209 | */ |
||
210 | public function useExtendedInsert($bool) |
||
215 | 4 | ||
216 | 4 | /** |
|
217 | * Use '--hex-blob' to encode binary fields. |
||
218 | * |
||
219 | * @param boolean $bool |
||
220 | * @return \phpbu\App\Cli\Executable\Mysqldump |
||
221 | */ |
||
222 | public function dumpBlobsHexadecimal($bool) |
||
227 | 4 | ||
228 | 4 | /** |
|
229 | * Set tables to dump. |
||
230 | * |
||
231 | * @param array $tables |
||
232 | * @return \phpbu\App\Cli\Executable\Mysqldump |
||
233 | */ |
||
234 | public function dumpTables(array $tables) |
||
239 | 4 | ||
240 | 4 | /** |
|
241 | * Set databases to dump. |
||
242 | * |
||
243 | * @param array $databases |
||
244 | * @return \phpbu\App\Cli\Executable\Mysqldump |
||
245 | */ |
||
246 | public function dumpDatabases(array $databases) |
||
251 | 4 | ||
252 | 4 | /** |
|
253 | * Set tables to ignore. |
||
254 | * |
||
255 | * @param array $tables |
||
256 | * @return \phpbu\App\Cli\Executable\Mysqldump |
||
257 | */ |
||
258 | public function ignoreTables(array $tables) |
||
263 | 4 | ||
264 | 4 | /** |
|
265 | * Set tables where only table structure should be dumped. |
||
266 | * |
||
267 | * @param array $tables |
||
268 | * @return \phpbu\App\Cli\Executable\Mysqldump |
||
269 | */ |
||
270 | public function dumpStructureOnly(array $tables) |
||
275 | 3 | ||
276 | 3 | /** |
|
277 | * Dump no table data at all. |
||
278 | * |
||
279 | * @param boolean $bool |
||
280 | * @return \phpbu\App\Cli\Executable\Mysqldump |
||
281 | */ |
||
282 | 11 | public function dumpNoData($bool) |
|
287 | |||
288 | /** |
||
289 | 11 | * Set the dump target path. |
|
290 | 11 | * |
|
291 | * @param string $path |
||
292 | 11 | * @return \phpbu\App\Cli\Executable\Mysqldump |
|
293 | 11 | */ |
|
294 | 11 | public function dumpTo($path) |
|
299 | 11 | ||
300 | /** |
||
301 | 11 | * Process generator |
|
302 | 1 | */ |
|
303 | 1 | protected function createProcess() |
|
356 | } |
||
357 |