Skip to content

Commit e3041f8

Browse files
committed
Add a replace mode (useful for appending incremental dumps)
1 parent fe3f322 commit e3041f8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fakedump.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
'data'=>true,
4444
'lock'=>false, //like --lock-tables in mysqldump
4545
'single'=>false, //like --single-transaction in mysqldump (for innodb tables)
46-
'complete'=>false,
47-
'extended'=>false,
46+
'complete'=>false, //get all the columns named in every insert/replace
47+
'extended'=>false, //get multiple rows per insert
48+
'replace'=>false, //set to true to get REPLACE INTO (eg to append, make sure the table as a key, and set schema=0 !)
4849

4950
//query to run (can be something as simple as "select * from aview")
5051
'select' => "select gridimage_id,user_id,realname,title from gridimage_search limit 100",
@@ -241,10 +242,11 @@ function escape_tsv($in) {
241242
}
242243
}
243244

245+
$insert = $p['replace']?'REPLACE':'INSERT';
244246
if ($p['complete']) {
245-
$insert = "INSERT INTO `{$p['table']}` (".implode(",",$names).") VALUES (";
247+
$insert .= " INTO `{$p['table']}` (".implode(",",$names).") VALUES (";
246248
} else {
247-
$insert = "INSERT INTO `{$p['table']}` VALUES (";
249+
$insert .= " INTO `{$p['table']}` VALUES (";
248250
}
249251

250252
$c = 0;

0 commit comments

Comments
 (0)