Code: Select all
function sqlite_drop_tables($database) {
print("* Dropping all tables: ");
// *** start transaction ***
$transaction = "begin;\n";
// *** get the list of tables ***
$table = sqlite_array_query($database, "select * from sqlite_master where type='table'", SQLITE_ASSOC);
if (is_array($table)) {
foreach($table as $this_table) {
// *** drop this table ***
$transaction .= sprintf("drop table %s;\n", $this_table['name']);
}
}
// *** end and commit transaction ***
if (sqlite_query($database, sprintf("%scommit;\n", $transaction))) {
print("Okay\n");
}
else {
print("Failed\n");
/* die($php_errormsg . "\n"); */
}
}Code: Select all
function sqlite_schema_setup($database, $path) {
printf("* Building database schema from %s: ", $path);
if ($setup_transaction = file_get_contents($path) and sqlite_query($database, $setup_transaction)) {
print("Okay\n");
}
else {
print("Failed\n");
die($php_errormsg . "\n");
}
}