mirror of
https://github.com/xevidos/codiad.git
synced 2024-11-10 21:26:35 +01:00
Added postgresql pull request
This commit is contained in:
commit
dfed2269c9
@ -87,13 +87,24 @@ if ( ! ( defined( "DBHOST" ) && defined( "DBNAME" ) && defined( "DBUSER" ) && de
|
||||
$project_path = $project_name;
|
||||
}
|
||||
$timezone = $_POST['timezone'];
|
||||
|
||||
|
||||
$dbtype = $_POST['dbtype'];
|
||||
$dbhost = $_POST['dbhost'];
|
||||
$dbname = $_POST['dbname'];
|
||||
$dbuser = $_POST['dbuser'];
|
||||
$dbpass = $_POST['dbpass'];
|
||||
|
||||
//Valid databases Codiad is able to use
|
||||
$aValidDBType = [
|
||||
'mysql'
|
||||
,'postgresql'
|
||||
];
|
||||
|
||||
//Is selected database type valid?
|
||||
if(!in_array($dbtype,$aValidDBType)){
|
||||
die( "Invalid database. Please select one of ".implode(", "$aValidDBType)."." );
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$connection = new PDO( "{$dbtype}:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass );
|
||||
@ -104,7 +115,8 @@ if ( ! ( defined( "DBHOST" ) && defined( "DBNAME" ) && defined( "DBUSER" ) && de
|
||||
}
|
||||
$bind_vars = array();
|
||||
$bind = "";
|
||||
$sql = "
|
||||
$sql = [];
|
||||
$sql['mysql'] = "
|
||||
|
||||
--
|
||||
-- Table structure for table options
|
||||
@ -164,11 +176,69 @@ CREATE TABLE IF NOT EXISTS user_options (
|
||||
CONSTRAINT option_name UNIQUE (name,username)
|
||||
);
|
||||
|
||||
";
|
||||
|
||||
$sql['postgresql'] = "
|
||||
|
||||
--
|
||||
-- Table structure for table options
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS options (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name varchar(255) NOT NULL UNIQUE,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table projects
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS projects (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name varchar(255) NOT NULL,
|
||||
path varchar(255) NOT NULL UNIQUE,
|
||||
owner varchar(255) NOT NULL UNIQUE,
|
||||
access text
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table users
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
first_name varchar(255) DEFAULT NULL,
|
||||
last_name varchar(255) DEFAULT NULL,
|
||||
username varchar(255) NOT NULL UNIQUE,
|
||||
password text NOT NULL,
|
||||
email varchar(255) DEFAULT NULL,
|
||||
project varchar(255) DEFAULT NULL,
|
||||
access varchar(255) NOT NULL,
|
||||
groups text,
|
||||
token text
|
||||
);
|
||||
|
||||
--
|
||||
-- Table structure for table user_options
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_options (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name varchar(255) NOT NULL UNIQUE,
|
||||
username varchar(255) NOT NULL UNIQUE,
|
||||
value text NOT NULL
|
||||
);
|
||||
|
||||
";
|
||||
|
||||
try {
|
||||
|
||||
$result = $connection->exec($sql);
|
||||
$result = $connection->exec($sql[$dbtype]);
|
||||
} catch( PDOException $e ) {
|
||||
|
||||
die($e->getMessage());
|
||||
|
Loading…
Reference in New Issue
Block a user