booleanise blotter
This commit is contained in:
parent
4a5863b750
commit
0c8c31b6c9
1 changed files with 15 additions and 24 deletions
|
@ -15,31 +15,26 @@ class Blotter extends Extension
|
||||||
|
|
||||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config, $database;
|
||||||
$version = $config->get_int("blotter_version", 0);
|
|
||||||
/**
|
if ($config->get_int("blotter_version", 0) < 1) {
|
||||||
* If this version is less than "1", it's time to install.
|
|
||||||
*
|
|
||||||
* REMINDER: If I change the database tables, I must change up version by 1.
|
|
||||||
*/
|
|
||||||
if ($version < 1) {
|
|
||||||
/**
|
|
||||||
* Installer
|
|
||||||
*/
|
|
||||||
global $database, $config;
|
|
||||||
$database->create_table("blotter", "
|
$database->create_table("blotter", "
|
||||||
id SCORE_AIPK,
|
id SCORE_AIPK,
|
||||||
entry_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
entry_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
entry_text TEXT NOT NULL,
|
entry_text TEXT NOT NULL,
|
||||||
important SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N
|
important BOOLEAN NOT NULL DEFAULT FALSE
|
||||||
");
|
");
|
||||||
// Insert sample data:
|
// Insert sample data:
|
||||||
$database->execute(
|
$database->execute(
|
||||||
"INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), :text, :important)",
|
"INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), :text, :important)",
|
||||||
["text"=>"Installed the blotter extension!", "important"=>"Y"]
|
["text"=>"Installed the blotter extension!", "important"=>true]
|
||||||
);
|
);
|
||||||
log_info("blotter", "Installed tables for blotter extension.");
|
log_info("blotter", "Installed tables for blotter extension.");
|
||||||
$config->set_int("blotter_version", 1);
|
$config->set_int("blotter_version", 2);
|
||||||
|
}
|
||||||
|
if ($config->get_int("blotter_version", 0) < 2) {
|
||||||
|
$database->standardise_boolean("blotter", "important");
|
||||||
|
$config->set_int("blotter_version", 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,11 +93,7 @@ class Blotter extends Extension
|
||||||
if ($entry_text == "") {
|
if ($entry_text == "") {
|
||||||
die("No entry message!");
|
die("No entry message!");
|
||||||
}
|
}
|
||||||
if (isset($_POST['important'])) {
|
$important = isset($_POST['important']);
|
||||||
$important = 'Y';
|
|
||||||
} else {
|
|
||||||
$important = 'N';
|
|
||||||
}
|
|
||||||
// Now insert into db:
|
// Now insert into db:
|
||||||
$database->execute(
|
$database->execute(
|
||||||
"INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), :text, :important)",
|
"INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), :text, :important)",
|
||||||
|
|
Reference in a new issue