Support multiple databases as well.
This commit is contained in:
parent
dd88127c30
commit
caec1ac824
@ -412,12 +412,34 @@ class Database {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a table from pseudo-SQL
|
||||
*/
|
||||
public function create_table($name, $data) {
|
||||
$this->execute($this->engine->create_table_sql($name, $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of tables present in the current database.
|
||||
*/
|
||||
public function count_tables() {
|
||||
if($this->engine->name === "mysql") {
|
||||
return count(
|
||||
$this->get_all("SHOW TABLES")
|
||||
);
|
||||
} else if ($this->engine->name === "pgsql") {
|
||||
return count(
|
||||
$this->get_all("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'")
|
||||
);
|
||||
} else if ($this->engine->name === "sqlite") {
|
||||
return count(
|
||||
$this->get_all(".tables")
|
||||
);
|
||||
} else {
|
||||
// Hard to find a universal way to do this...
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
@ -300,7 +300,7 @@ function create_tables() { // {{{
|
||||
try {
|
||||
$db = new Database();
|
||||
|
||||
if ( count($db->get_all("SHOW TABLES")) > 0 ) {
|
||||
if ( $db->count_tables() > 0 ) {
|
||||
echo "
|
||||
<p>Warning: The Database schema is not empty!</p>
|
||||
<p>Please ensure that the database you are installing Shimmie with is empty before continuing.</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user