Notifications

This commit is contained in:
2020-04-02 21:19:06 +02:00
parent 541b8563d5
commit d7a5897fc9
24 changed files with 469 additions and 429 deletions

View File

@@ -36,15 +36,6 @@ class PostgreSQL extends SQL {
return 'pgsql';
}
public function getLastError() {
$lastError = parent::getLastError();
if (empty($lastError)) {
$lastError = pg_last_error($this->connection) . " " . pg_last_error($this->connection);
}
return $lastError;
}
// Connection Managment
public function connect() {
if(!is_null($this->connection)) {
@@ -84,6 +75,15 @@ class PostgreSQL extends SQL {
pg_close($this->connection);
}
public function getLastError() {
$lastError = parent::getLastError();
if (empty($lastError)) {
$lastError = pg_last_error($this->connection) . " " . pg_last_error($this->connection);
}
return $lastError;
}
protected function execute($query, $values = NULL, $returnValues = false) {
$this->lastError = "";
@@ -136,30 +136,6 @@ class PostgreSQL extends SQL {
}
// Querybuilder
public function executeCreateTable($createTable) {
$tableName = $this->tableName($createTable->getTableName());
$ifNotExists = $createTable->ifNotExists() ? " IF NOT EXISTS": "";
$entries = array();
foreach($createTable->getColumns() as $column) {
$entries[] = ($tmp = $this->getColumnDefinition($column));
if (is_null($tmp)) {
return false;
}
}
foreach($createTable->getConstraints() as $constraint) {
$entries[] = ($tmp = $this->getConstraintDefinition($constraint));
if (is_null($tmp)) {
return false;
}
}
$entries = implode(",", $entries);
$query = "CREATE TABLE$ifNotExists $tableName ($entries)";
return $this->execute($query);
}
public function executeInsert($insert) {
$tableName = $this->tableName($insert->getTableName());
@@ -408,7 +384,7 @@ class PostgreSQL extends SQL {
if ($val instanceof Keyword) {
return $val->getValue();
} else {
$params[] = $val;
$params[] = is_bool($val) ? ($val ? "TRUE" : "FALSE") : $val;
return '$' . count($params);
}
}
@@ -449,13 +425,5 @@ class PostgreSQL extends SQL {
public function currentTimestamp() {
return new Keyword("CURRENT_TIMESTAMP");
}
public function count($col = NULL) {
if (is_null($col)) {
return new Keyword("COUNT(*) AS count");
} else {
return new Keyword("COUNT(" . $this->columnName($col) . ") AS count");
}
}
}
?>