implemented mysql backup methods
This commit is contained in:
parent
fd4a9e1587
commit
257609168e
@ -401,7 +401,7 @@ abstract class DB_PDO extends PDO {
|
|||||||
* @param bool $filtered_index
|
* @param bool $filtered_index
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function driver_query($sql, $filtered_index=TRUE)
|
public function driver_query($sql, $filtered_index=TRUE)
|
||||||
{
|
{
|
||||||
// Return if the query doesn't apply to the driver
|
// Return if the query doesn't apply to the driver
|
||||||
if ($sql === FALSE)
|
if ($sql === FALSE)
|
||||||
|
@ -124,30 +124,30 @@ class MySQL_Util extends DB_Util {
|
|||||||
*/
|
*/
|
||||||
public function backup_structure()
|
public function backup_structure()
|
||||||
{
|
{
|
||||||
$sql = '';
|
$string = array();
|
||||||
|
|
||||||
// Get databases
|
// Get databases
|
||||||
$dbs = $this->conn->get_dbs();
|
$dbs = $this->get_dbs();
|
||||||
|
|
||||||
foreach($dbs as &$d)
|
foreach($dbs as &$d)
|
||||||
{
|
{
|
||||||
// Get the list of tables
|
// Skip built-in dbs
|
||||||
$tables = $this->conn->driver_query("SHOW TABLES FROM `{$database}`");
|
if ($d == 'mysql')
|
||||||
|
|
||||||
// Get the list of views
|
|
||||||
$views = $this->conn->driver_query("SHOW VIEWS FROM `{$database}`");
|
|
||||||
|
|
||||||
$tav = array_merge($tabes,$views);
|
|
||||||
|
|
||||||
foreach($tav as &$table)
|
|
||||||
{
|
{
|
||||||
$string = $this->conn->driver_query("SHOW CREATE TABLE {$table}");
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the list of tables
|
||||||
|
$tables = $this->driver_query("SHOW TABLES FROM `{$d}`");
|
||||||
|
|
||||||
|
foreach($tables as &$table)
|
||||||
|
{
|
||||||
|
$array = $this->driver_query("SHOW CREATE TABLE `{$d}`.`{$table}`", FALSE);
|
||||||
|
$string[] = $array[0]['Create Table'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Implement Backup function
|
return implode("\n\n", $string);
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
@ -192,4 +192,9 @@ SQL;
|
|||||||
{
|
{
|
||||||
$this->assertFalse($this->db->get_sequences());
|
$this->assertFalse($this->db->get_sequences());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function TestBackup()
|
||||||
|
{
|
||||||
|
$this->assertTrue(is_string($this->db->util->backup_structure()));
|
||||||
|
}
|
||||||
}
|
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user