sqlite engine
This commit is contained in:
parent
d98962a30e
commit
8619be809e
2 changed files with 22 additions and 3 deletions
|
@ -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 {
|
||||
|
|
|
@ -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", "
|
||||
|
|
Reference in a new issue