diff --git a/core/database.class.php b/core/database.class.php index 71cd2110..02356293 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -56,6 +56,8 @@ class DBEngine { var $inet = null; var $create_table_extras = ""; + public function init($db) {} + public function create_table_sql($name, $data) { return "CREATE TABLE $name ($data)"; } @@ -81,9 +83,6 @@ class MySQL extends DBEngine { class PostgreSQL extends DBEngine { var $name = "pgsql"; - public function init($db) { - } - public function create_table_sql($name, $data) { $data = str_replace("SCORE_AIPK", "SERIAL PRIMARY KEY", $data); $data = str_replace("SCORE_INET", "INET", $data); @@ -94,6 +93,19 @@ class PostgreSQL extends DBEngine { return "CREATE TABLE $name ($data)"; } } +class SQLite extends DBEngine { + var $name = "sqlite"; + + public function create_table_sql($name, $data) { + $data = str_replace("SCORE_AIPK", "INTEGER PRIMARY KEY", $data); + $data = str_replace("SCORE_INET", "INET", $data); + $data = str_replace("SCORE_BOOL_Y", "'Y'", $data); + $data = str_replace("SCORE_BOOL_N", "'N'", $data); + $data = str_replace("SCORE_BOOL", "BOOL", $data); + $data = str_replace("SCORE_NOW", "current_time", $data); + return "CREATE TABLE $name ($data)"; + } +} // }}} // {{{ cache engines interface CacheEngine { diff --git a/install.php b/install.php index 46195d7b..3e421108 100644 --- a/install.php +++ b/install.php @@ -149,6 +149,13 @@ function create_tables($dsn) { // {{{ else if(substr($dsn, 0, 5) == "pgsql") { $engine = new PostgreSQL(); } + else if(substr($dsn, 0, 5) == "sqlite") { + $engine = new SQLite(); + } + else { + die("Unknown database engine; Shimmie currently officially supports MySQL + (mysql://), with hacks for Postgres (pgsql://) and SQLite (sqlite://)"); + } $engine->init($db); $db->execute($engine->create_table_sql("aliases", "