Revision 326
Added by stefan over 19 years ago
| trunk/wb/modules/backup/backup-sql.php | ||
|---|---|---|
| 49 | 49 |
"\n"; |
| 50 | 50 |
|
| 51 | 51 |
// Get table names |
| 52 |
$result = $database->query("SHOW TABLE STATUS");
|
|
| 52 |
$result = $database->query("SHOW TABLES");
|
|
| 53 | 53 |
|
| 54 | 54 |
// Loop through tables |
| 55 | 55 |
while($row = $result->fetchRow()) {
|
| 56 | 56 |
//show sql query to rebuild the query |
| 57 |
$sql = 'SHOW CREATE TABLE '.$row['Name'].'';
|
|
| 57 |
$sql = 'SHOW CREATE TABLE '.$row[0].'';
|
|
| 58 | 58 |
$query2 = $database->query($sql); |
| 59 | 59 |
// Start creating sql-backup |
| 60 |
$sql_backup ="\r\n# Create table ".$row['Name']."\r\n\r\n";
|
|
| 60 |
$sql_backup ="\r\n# Create table ".$row[0]."\r\n\r\n";
|
|
| 61 | 61 |
$out = $query2->fetchRow(); |
| 62 | 62 |
$sql_backup.=$out['Create Table'].";\r\n\r\n"; |
| 63 |
$sql_backup.="# Dump data for ".$row['Name']."\r\n\r\n";
|
|
| 63 |
$sql_backup.="# Dump data for ".$row[0]."\r\n\r\n";
|
|
| 64 | 64 |
// Select everything |
| 65 |
$out = $database->query('SELECT * FROM '.$row['Name']);
|
|
| 65 |
$out = $database->query('SELECT * FROM '.$row[0]);
|
|
| 66 | 66 |
$sql_code = ''; |
| 67 | 67 |
// Loop through all collumns |
| 68 | 68 |
while($code = $out->fetchRow()) {
|
| 69 |
$sql_code .= "INSERT INTO ".$row['Name']." SET ";
|
|
| 69 |
$sql_code .= "INSERT INTO ".$row[0]." SET ";
|
|
| 70 | 70 |
$numeral = 0; |
| 71 | 71 |
foreach($code as $insert => $value) {
|
| 72 | 72 |
// Loosing the numerals in array -> mysql_fetch_array($result, MYSQL_ASSOC) WB hasn't? |
Also available in: Unified diff
John: fixed ticket #82 backup module.