}
function query($query, $die_on_error = true) {
- $result = mysql_query($query, $this->link);
+ $result = @mysql_query($query, $this->link);
if (!$result) {
- user_error("Query $query failed: " . ($this->link ? mysql_error($this->link) : "No connection"),
+ $error = @mysql_error($this->link);
+
+ @mysql_query("ROLLBACK", $this->link);
+ user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
$die_on_error ? E_USER_ERROR : E_USER_WARNING);
}
return $result;
}
function query($query, $die_on_error = true) {
- $result = mysqli_query($this->link, $query);
+ $result = @mysqli_query($this->link, $query);
if (!$result) {
- user_error("Query $query failed: " . ($this->link ? mysqli_error($this->link) : "No connection"),
+ $error = @mysqli_error($this->link);
+
+ @mysqli_query($this->link, "ROLLBACK");
+ user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
$die_on_error ? E_USER_ERROR : E_USER_WARNING);
}
}
function query($query, $die_on_error = true) {
- $result = pg_query($query);
+ $result = @pg_query($this->link, $query);
if (!$result) {
+ $error = @pg_last_error($this->link);
+
+ @pg_query($this->link, "ROLLBACK");
$query = htmlspecialchars($query); // just in case
- user_error("Query $query failed: " . ($this->link ? pg_last_error($this->link) : "No connection"),
+ user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
$die_on_error ? E_USER_ERROR : E_USER_WARNING);
}
return $result;