psql fix
This commit is contained in:
parent
b3bded2332
commit
186083a315
28
cli.php
28
cli.php
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once 'core/core.php';
|
include_once 'core/core.php';
|
||||||
|
include_once 'core/constants.php';
|
||||||
|
|
||||||
|
use Configuration\DatabaseScript;
|
||||||
use Driver\SQL\SQL;
|
use Driver\SQL\SQL;
|
||||||
use Objects\ConnectionData;
|
use Objects\ConnectionData;
|
||||||
|
|
||||||
@ -44,7 +46,33 @@ function handleDatabase($argv) {
|
|||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'migrate':
|
case 'migrate':
|
||||||
|
$class = $argv[3] ?? null;
|
||||||
|
if (!$class) {
|
||||||
|
die("Usage: cli.php db migrate <class name>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
$class = str_replace('/', '\\', $class);
|
||||||
|
$className = "\\Configuration\\$class";
|
||||||
|
$classPath = getClassPath($className);
|
||||||
|
if (!file_exists($classPath) || !is_readable($classPath)) {
|
||||||
|
die("Database script file does not exist or is not readable\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once $classPath;
|
||||||
|
$obj = new $className();
|
||||||
|
if (!($obj instanceof DatabaseScript)) {
|
||||||
|
die("Not a database script\n");
|
||||||
|
}
|
||||||
|
|
||||||
$db = connectDatabase();
|
$db = connectDatabase();
|
||||||
|
$queries = $obj->createQueries($db);
|
||||||
|
foreach ($queries as $query) {
|
||||||
|
if (!$query->execute($db)) {
|
||||||
|
die($db->getLastError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->close();
|
||||||
break;
|
break;
|
||||||
case 'export':
|
case 'export':
|
||||||
$config = getDatabaseConfig();
|
$config = getDatabaseConfig();
|
||||||
|
@ -126,7 +126,8 @@ class CreateDatabase extends DatabaseScript {
|
|||||||
->addString("target", 128)
|
->addString("target", 128)
|
||||||
->addString("extra", 64, true)
|
->addString("extra", 64, true)
|
||||||
->addBool("active", true)
|
->addBool("active", true)
|
||||||
->primaryKey("uid");
|
->primaryKey("uid")
|
||||||
|
->unique("request");
|
||||||
|
|
||||||
$queries[] = $sql->insert("Route", array("request", "action", "target", "extra"))
|
$queries[] = $sql->insert("Route", array("request", "action", "target", "extra"))
|
||||||
->addRow("^/admin(/.*)?$", "dynamic", "\\Documents\\Admin", NULL)
|
->addRow("^/admin(/.*)?$", "dynamic", "\\Documents\\Admin", NULL)
|
||||||
|
@ -280,9 +280,7 @@ namespace Documents\Install {
|
|||||||
$success = false;
|
$success = false;
|
||||||
$msg = "Unable to write file";
|
$msg = "Unable to write file";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($sql) {
|
|
||||||
$sql->close();
|
$sql->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ class PostgreSQL extends SQL {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->connection = @pg_connect(implode(" ", $connectionString));
|
$this->connection = @pg_connect(implode(" ", $connectionString), PGSQL_CONNECT_FORCE_NEW);
|
||||||
if (!$this->connection) {
|
if (!$this->connection) {
|
||||||
$this->lastError = "Failed to connect to Database";
|
$this->lastError = "Failed to connect to Database";
|
||||||
$this->connection = NULL;
|
$this->connection = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user