+ $res = $this->dbh->simpleQuery($query);
+ if(DB::isError($res)) {
+ $this->failQuery($res);
+ }
+ }
+ } elseif ($this->db_type == SMDB_PGSQL) {
+ if ($use_pdo) {
+ if ($this->dbh->exec('BEGIN TRANSACTION') === FALSE) {
+ if ($pdo_show_sql_errors)
+ $this->error = implode(' - ', $this->dbh->errorInfo());
+ else
+ $this->error = _("Could not execute query");
+ $this->failQuery();
+ }
+ if (!($sth = $this->dbh->prepare('DELETE FROM ' . $this->identifier_quote_char . $this->table . $this->identifier_quote_char . ' WHERE ' . $this->identifier_quote_char . $this->user_field . $this->identifier_quote_char . ' = ? AND ' . $this->identifier_quote_char . $this->key_field . $this->identifier_quote_char . ' = ?'))) {
+ if ($pdo_show_sql_errors)
+ $this->error = implode(' - ', $this->dbh->errorInfo());
+ else
+ $this->error = _("Could not prepare query");
+ $this->failQuery();
+ }
+ if (!($res = $sth->execute(array($user, $key)))) {
+ if ($pdo_show_sql_errors)
+ $this->error = implode(' - ', $sth->errorInfo());
+ else
+ $this->error = _("Could not execute query");
+ $this->dbh->exec('ROLLBACK TRANSACTION');
+ $this->failQuery();
+ }
+ if (!($sth = $this->dbh->prepare('INSERT INTO ' . $this->identifier_quote_char . $this->table . $this->identifier_quote_char . ' (' . $this->identifier_quote_char . $this->user_field . $this->identifier_quote_char . ', ' . $this->identifier_quote_char . $this->key_field . $this->identifier_quote_char . ', ' . $this->identifier_quote_char . $this->val_field . $this->identifier_quote_char . ') VALUES (?, ?, ?)'))) {
+ if ($pdo_show_sql_errors)
+ $this->error = implode(' - ', $this->dbh->errorInfo());
+ else
+ $this->error = _("Could not prepare query");
+ $this->failQuery();
+ }
+ if (!($res = $sth->execute(array($user, $key, $value)))) {
+ if ($pdo_show_sql_errors)
+ $this->error = implode(' - ', $sth->errorInfo());
+ else
+ $this->error = _("Could not execute query");
+ $this->dbh->exec('ROLLBACK TRANSACTION');
+ $this->failQuery();
+ }
+ if ($this->dbh->exec('COMMIT TRANSACTION') === FALSE) {
+ if ($pdo_show_sql_errors)
+ $this->error = implode(' - ', $this->dbh->errorInfo());
+ else
+ $this->error = _("Could not execute query");
+ $this->failQuery();
+ }
+ } else {
+ $this->dbh->simpleQuery("BEGIN TRANSACTION");
+ $query = sprintf("DELETE FROM %s WHERE %s='%s' AND %s='%s'",
+ $this->table,
+ $this->user_field,
+ $this->dbh->quoteString($user),
+ $this->key_field,
+ $this->dbh->quoteString($key));
+ $res = $this->dbh->simpleQuery($query);
+ if (DB::isError($res)) {
+ $this->dbh->simpleQuery("ROLLBACK TRANSACTION");
+ $this->failQuery($res);
+ }
+ $query = sprintf("INSERT INTO %s (%s, %s, %s) VALUES ('%s', '%s', '%s')",
+ $this->table,
+ $this->user_field,
+ $this->key_field,
+ $this->val_field,
+ $this->dbh->quoteString($user),
+ $this->dbh->quoteString($key),
+ $this->dbh->quoteString($value));
+ $res = $this->dbh->simpleQuery($query);
+ if (DB::isError($res)) {
+ $this->dbh->simpleQuery("ROLLBACK TRANSACTION");
+ $this->failQuery($res);
+ }
+ $this->dbh->simpleQuery("COMMIT TRANSACTION");
+ }
+ } else {
+ if ($use_pdo) {
+ if (!($sth = $this->dbh->prepare('DELETE FROM ' . $this->identifier_quote_char . $this->table . $this->identifier_quote_char . ' WHERE ' . $this->identifier_quote_char . $this->user_field . $this->identifier_quote_char . ' = ? AND ' . $this->identifier_quote_char . $this->key_field . $this->identifier_quote_char . ' = ?'))) {
+ if ($pdo_show_sql_errors)
+ $this->error = implode(' - ', $this->dbh->errorInfo());
+ else
+ $this->error = _("Could not prepare query");
+ $this->failQuery();
+ }
+ if (!($res = $sth->execute(array($user, $key)))) {
+ if ($pdo_show_sql_errors)
+ $this->error = implode(' - ', $sth->errorInfo());
+ else
+ $this->error = _("Could not execute query");
+ $this->failQuery();
+ }
+ if (!($sth = $this->dbh->prepare('INSERT INTO ' . $this->identifier_quote_char . $this->table . $this->identifier_quote_char . ' (' . $this->identifier_quote_char . $this->user_field . $this->identifier_quote_char . ', ' . $this->identifier_quote_char . $this->key_field . $this->identifier_quote_char . ', ' . $this->identifier_quote_char . $this->val_field . $this->identifier_quote_char . ') VALUES (?, ?, ?)'))) {
+ if ($pdo_show_sql_errors)
+ $this->error = implode(' - ', $this->dbh->errorInfo());
+ else
+ $this->error = _("Could not prepare query");
+ $this->failQuery();
+ }
+ if (!($res = $sth->execute(array($user, $key, $value)))) {
+ if ($pdo_show_sql_errors)
+ $this->error = implode(' - ', $sth->errorInfo());
+ else
+ $this->error = _("Could not execute query");
+ $this->failQuery();
+ }
+ } else {
+ $query = sprintf("DELETE FROM %s WHERE %s='%s' AND %s='%s'",
+ $this->table,
+ $this->user_field,
+ $this->dbh->quoteString($user),
+ $this->key_field,
+ $this->dbh->quoteString($key));
+ $res = $this->dbh->simpleQuery($query);
+ if (DB::isError($res)) {
+ $this->failQuery($res);
+ }
+ $query = sprintf("INSERT INTO %s (%s, %s, %s) VALUES ('%s', '%s', '%s')",
+ $this->table,
+ $this->user_field,
+ $this->key_field,
+ $this->val_field,
+ $this->dbh->quoteString($user),
+ $this->dbh->quoteString($key),
+ $this->dbh->quoteString($value));
+ $res = $this->dbh->simpleQuery($query);
+ if (DB::isError($res)) {
+ $this->failQuery($res);
+ }
+ }