|
|
@ -1,6 +1,7 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
class Db_Pgsql implements IDb {
|
|
|
|
class Db_Pgsql implements IDb {
|
|
|
|
private $link;
|
|
|
|
private $link;
|
|
|
|
|
|
|
|
private $last_error;
|
|
|
|
|
|
|
|
|
|
|
|
function connect($host, $user, $pass, $db, $port) {
|
|
|
|
function connect($host, $user, $pass, $db, $port) {
|
|
|
|
$string = "dbname=$db user=$user";
|
|
|
|
$string = "dbname=$db user=$user";
|
|
|
@ -38,11 +39,11 @@ class Db_Pgsql implements IDb {
|
|
|
|
$result = @pg_query($this->link, $query);
|
|
|
|
$result = @pg_query($this->link, $query);
|
|
|
|
|
|
|
|
|
|
|
|
if (!$result) {
|
|
|
|
if (!$result) {
|
|
|
|
$error = @pg_last_error($this->link);
|
|
|
|
$this->last_error = @pg_last_error($this->link);
|
|
|
|
|
|
|
|
|
|
|
|
@pg_query($this->link, "ROLLBACK");
|
|
|
|
@pg_query($this->link, "ROLLBACK");
|
|
|
|
$query = htmlspecialchars($query); // just in case
|
|
|
|
$query = htmlspecialchars($query); // just in case
|
|
|
|
user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
|
|
|
|
user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"),
|
|
|
|
$die_on_error ? E_USER_ERROR : E_USER_WARNING);
|
|
|
|
$die_on_error ? E_USER_ERROR : E_USER_WARNING);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
@ -73,6 +74,10 @@ class Db_Pgsql implements IDb {
|
|
|
|
return pg_last_error($this->link);
|
|
|
|
return pg_last_error($this->link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function last_query_error() {
|
|
|
|
|
|
|
|
return $this->last_error;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
function init() {
|
|
|
|
$this->query("set client_encoding = 'UTF-8'");
|
|
|
|
$this->query("set client_encoding = 'UTF-8'");
|
|
|
|
pg_set_client_encoding("UNICODE");
|
|
|
|
pg_set_client_encoding("UNICODE");
|
|
|
|