1 | <?php |
||
10 | class Database |
||
11 | { |
||
12 | use Debugger; |
||
13 | |||
14 | /** |
||
15 | * MySQL and MySQLDump login arguments. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | private $credentials = '-u%s -p%s -h%s -P%s'; |
||
20 | /** |
||
21 | * Name of original database. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | private $source = ''; |
||
26 | /** |
||
27 | * Name of temporary database that will store data from original. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | private $temporary = ''; |
||
32 | /** |
||
33 | * Indicates that DB was cloned. |
||
34 | * |
||
35 | * @var bool |
||
36 | */ |
||
37 | private $cloned = false; |
||
38 | |||
39 | /** |
||
40 | * @param string $connection |
||
41 | * Database connection name (key in $databases array from settings.php). |
||
42 | */ |
||
43 | public function __construct($connection) |
||
71 | |||
72 | /** |
||
73 | * Clone a database. |
||
74 | */ |
||
75 | public function __clone() |
||
81 | |||
82 | /** |
||
83 | * Restore original database. |
||
84 | */ |
||
85 | public function __destruct() |
||
94 | |||
95 | /** |
||
96 | * @param string $name |
||
97 | * Name of the database to check. |
||
98 | * |
||
99 | * @return bool |
||
100 | * Checking state. |
||
101 | */ |
||
102 | public function exist($name) |
||
106 | |||
107 | /** |
||
108 | * @param string $name |
||
109 | * Name of the database to drop. |
||
110 | */ |
||
111 | public function drop($name) |
||
117 | |||
118 | /** |
||
119 | * @param string $name |
||
120 | * Name of the database to create. |
||
121 | */ |
||
122 | public function create($name) |
||
128 | |||
129 | /** |
||
130 | * @param string $source |
||
131 | * Source DB name. |
||
132 | * @param string $destination |
||
133 | * Name of the new DB. |
||
134 | */ |
||
135 | public function copy($source, $destination) |
||
141 | |||
142 | /** |
||
143 | * Executes a shell command. |
||
144 | * |
||
145 | * @param string $command |
||
146 | * Command to execute. |
||
147 | * |
||
148 | * @return string |
||
149 | * Result of a shell command. |
||
150 | */ |
||
151 | private function exec($command) |
||
164 | } |
||
165 |