1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-25 14:31:28 +00:00

actually check for failures properly in the dbupdater

This commit is contained in:
Andrew Dolgov
2016-04-26 20:04:24 +03:00
parent 9e84bab449
commit 977cea1438
9 changed files with 44 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
<?php
class Db_Pgsql implements IDb {
private $link;
private $last_error;
function connect($host, $user, $pass, $db, $port) {
$string = "dbname=$db user=$user";
@@ -38,11 +39,11 @@ class Db_Pgsql implements IDb {
$result = @pg_query($this->link, $query);
if (!$result) {
$error = @pg_last_error($this->link);
$this->last_error = @pg_last_error($this->link);
@pg_query($this->link, "ROLLBACK");
$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);
}
return $result;
@@ -73,6 +74,10 @@ class Db_Pgsql implements IDb {
return pg_last_error($this->link);
}
function last_query_error() {
return $this->last_error;
}
function init() {
$this->query("set client_encoding = 'UTF-8'");
pg_set_client_encoding("UNICODE");