1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
<?php
// place paths to your files here
$src_path = '';
$dst_path = '';
$src = new SQLite3($src_path);
$dst = new SQLite3($dst_path);
function copy_canonical_addresses() {
global $src, $dst;
$q = $src->query("SELECT * FROM canonical_addresses");
while ($row = $q->fetchArray(SQLITE3_ASSOC)) {
$dst->query("INSERT INTO canonical_addresses (_id, address) VALUES (".$row['_id'].", '".SQLite3::escapeString($row['address'])."')");
}
}
function copy_sms() {
global $src, $dst;
$q = $src->query("SELECT * FROM sms");
while ($row = $q->fetchArray(SQLITE3_ASSOC)) {
$keys = [];
$values = [];
foreach ($row as $key => $value) {
$keys[] = "`".$key."`";
$values[] = "'".SQLite3::escapeString($value)."'";
}
$dst->query("INSERT INTO sms (".implode(', ', $keys).") VALUES (".implode(', ', $values).")");
}
}
function copy_threads() {
global $src, $dst;
$q = $src->query("SELECT * FROM threads");
while ($row = $q->fetchArray(SQLITE3_ASSOC)) {
$keys = [];
$values = [];
foreach ($row as $key => $value) {
if ($key == 'unread_message_count') {
continue;
}
$keys[] = "`".$key."`";
$values[] = "'".SQLite3::escapeString($value)."'";
}
$dst->query("INSERT INTO threads (".implode(', ', $keys).") VALUES (".implode(', ', $values).")");
}
}
function copy_words() {
global $src, $dst;
$tables = ['words', 'words_content', 'words_segments', 'words_segdir'];
foreach ($tables as $table) {
$q = $src->query("SELECT * FROM {$table}");
while ($row = $q->fetchArray(SQLITE3_ASSOC)) {
$keys = [];
$values = [];
foreach ($row as $key => $value) {
$keys[] = "`".$key."`";
$values[] = "'".SQLite3::escapeString($value)."'";
}
$dst->query("INSERT INTO {$table} (".implode(', ', $keys).") VALUES (".implode(', ', $values).")");
}
}
}
copy_threads();
copy_words();
copy_sms();
copy_canonical_addresses();
|