Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 256 → Rev 257

/trunk/plugins/database/pdo/plugin.inc.php
20,8 → 20,7
if (!defined('IN_OIDPLUS')) die();
 
class OIDplusDatabasePluginPDO extends OIDplusDatabasePlugin {
private $pdo;
private $last_query;
private $conn;
 
public static function getPluginInformation(): array {
$out = array();
39,13 → 38,12
private $last_error = null;
 
public function query(string $sql, /*?array*/ $prepared_args=null): OIDplusQueryResult {
$this->last_query = $sql;
$this->last_error = null;
if (is_null($prepared_args)) {
$res = $this->pdo->query($sql);
$res = $this->conn->query($sql);
 
if ($res === false) {
$this->last_error = $this->pdo->errorInfo()[2];
$this->last_error = $this->conn->errorInfo()[2];
throw new OIDplusSQLException($sql, $this->error());
} else {
return new OIDplusQueryResultPDO($res);
61,7 → 59,7
$sql = substr_replace($sql, $replace, $pos, strlen($needle));
}
}
return OIDplusQueryResultPDO($this->pdo->query($sql));
return OIDplusQueryResultPDO($this->conn->query($sql));
*/
 
if (!is_array($prepared_args)) {
76,7 → 74,7
if (is_bool($value)) $value = $value ? '1' : '0';
}
$ps = $this->pdo->prepare($sql);
$ps = $this->conn->prepare($sql);
if (!$ps) {
throw new OIDplusSQLException($sql, 'Cannot prepare statement');
}
91,7 → 89,7
}
 
public function insert_id(): int {
return $this->pdo->lastInsertId();
return $this->conn->lastInsertId();
}
 
public function error(): string {
109,7 → 107,7
];
 
// Try connecting to the database
$this->pdo = new PDO(OIDPLUS_PDO_DSN, OIDPLUS_PDO_USERNAME, base64_decode(OIDPLUS_PDO_PASSWORD), $options);
$this->conn = new PDO(OIDPLUS_PDO_DSN, OIDPLUS_PDO_USERNAME, base64_decode(OIDPLUS_PDO_PASSWORD), $options);
} catch (PDOException $e) {
$message = $e->getMessage();
throw new OIDplusConfigInitializationException('Connection to the database failed! '.$message);
119,7 → 117,7
}
 
protected function doDisconnect(): void {
$this->pdo = null; // the connection will be closed by removing the reference
$this->conn = null; // the connection will be closed by removing the reference
}
 
private $intransaction = false;
126,17 → 124,17
 
public function transaction_begin(): void {
if ($this->intransaction) throw new OIDplusException("Nested transactions are not supported by this database plugin.");
$this->pdo->beginTransaction();
$this->conn->beginTransaction();
$this->intransaction = true;
}
 
public function transaction_commit(): void {
$this->pdo->commit();
$this->conn->commit();
$this->intransaction = false;
}
 
public function transaction_rollback(): void {
$this->pdo->rollBack();
$this->conn->rollBack();
$this->intransaction = false;
}
}