aaaaaaaargh dates and times in sql

This commit is contained in:
Shish 2009-07-15 23:29:14 +01:00
parent dd650a6a4e
commit 96e69c4f20
2 changed files with 4 additions and 2 deletions

View file

@ -72,6 +72,7 @@ class MySQL extends DBEngine {
$data = str_replace("SCORE_BOOL_Y", "'Y'", $data); $data = str_replace("SCORE_BOOL_Y", "'Y'", $data);
$data = str_replace("SCORE_BOOL_N", "'N'", $data); $data = str_replace("SCORE_BOOL_N", "'N'", $data);
$data = str_replace("SCORE_BOOL", "ENUM('Y', 'N')", $data); $data = str_replace("SCORE_BOOL", "ENUM('Y', 'N')", $data);
$data = str_replace("SCORE_DATETIME", "DATETIME", $data);
$data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data); $data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data);
$ctes = "TYPE=InnoDB DEFAULT CHARSET='utf8'"; $ctes = "TYPE=InnoDB DEFAULT CHARSET='utf8'";
return "CREATE TABLE $name ($data) $ctes"; return "CREATE TABLE $name ($data) $ctes";
@ -86,6 +87,7 @@ class PostgreSQL extends DBEngine {
$data = str_replace("SCORE_BOOL_Y", "'t'", $data); $data = str_replace("SCORE_BOOL_Y", "'t'", $data);
$data = str_replace("SCORE_BOOL_N", "'f'", $data); $data = str_replace("SCORE_BOOL_N", "'f'", $data);
$data = str_replace("SCORE_BOOL", "BOOL", $data); $data = str_replace("SCORE_BOOL", "BOOL", $data);
$data = str_replace("SCORE_DATETIME", "TIMESTAMP", $data);
$data = str_replace("SCORE_NOW", "current_time", $data); $data = str_replace("SCORE_NOW", "current_time", $data);
return "CREATE TABLE $name ($data)"; return "CREATE TABLE $name ($data)";
} }

View file

@ -197,7 +197,7 @@ function create_tables($dsn) { // {{{
id SCORE_AIPK, id SCORE_AIPK,
name VARCHAR(32) UNIQUE NOT NULL, name VARCHAR(32) UNIQUE NOT NULL,
pass CHAR(32), pass CHAR(32),
joindate DATETIME NOT NULL DEFAULT SCORE_NOW, joindate SCORE_DATETIME NOT NULL DEFAULT SCORE_NOW,
admin SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, admin SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
email VARCHAR(128) email VARCHAR(128)
")); "));
@ -212,7 +212,7 @@ function create_tables($dsn) { // {{{
source VARCHAR(255), source VARCHAR(255),
width INTEGER NOT NULL, width INTEGER NOT NULL,
height INTEGER NOT NULL, height INTEGER NOT NULL,
posted TIMESTAMP NOT NULL DEFAULT SCORE_NOW, posted SCORE_DATETIME NOT NULL DEFAULT SCORE_NOW,
locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
INDEX(owner_id), INDEX(owner_id),
INDEX(width), INDEX(width),