abstract class Horde_Db_Adapter_Base implements Horde_Db_Adapter
{
/**
+ * The last query sent to the database.
+ *
+ * @var string
+ */
+ public $last_query;
+
+ /**
* Config options.
*
* @var array
$t->push();
try {
+ $this->last_query = $sql;
$stmt = $this->_connection->query($sql);
} catch (Exception $e) {
$this->_logError($sql, 'QUERY FAILED: ' . $e->getMessage());
$t = new Horde_Support_Timer();
$t->push();
+ $this->last_query = $sql;
$stmt = mysql_query($sql, $this->_connection);
if (!$stmt) {
$this->_logInfo($sql, 'QUERY FAILED: ' . mysql_error($this->_connection));
public function beginDbTransaction()
{
$this->_transactionStarted = true;
+ $this->last_query = 'SET AUTOCOMMIT=0; BEGIN';
@mysql_query('SET AUTOCOMMIT=0', $this->_connection) && @mysql_query('BEGIN', $this->_connection);
}
*/
public function commitDbTransaction()
{
+ $this->last_query = 'COMMIT; SET AUTOCOMMIT=1';
@mysql_query('COMMIT', $this->_connection) && @mysql_query('SET AUTOCOMMIT=1', $this->_connection);
$this->_transactionStarted = false;
}
*/
public function rollbackDbTransaction()
{
- if (! $this->_transactionStarted) { return; }
+ if (!$this->_transactionStarted) {
+ return;
+ }
+ $this->last_query = 'ROLLBACK; SET AUTOCOMMIT=1';
@mysql_query('ROLLBACK', $this->_connection) && @mysql_query('SET AUTOCOMMIT=1', $this->_connection);
$this->_transactionStarted = false;
}
*/
public function isActive()
{
+ $this->last_query = 'SELECT 1';
return isset($this->_connection) && $this->_connection->query('SELECT 1');
}
$t = new Horde_Support_Timer();
$t->push();
+ $this->last_query = $sql;
$stmt = $this->_connection->query($sql);
if (!$stmt) {
$this->_logInfo($sql, 'QUERY FAILED: ' . $this->_connection->error);
*/
public function isActive()
{
+ $this->last_query = 'SELECT 1';
return isset($this->_connection) &&
$this->_connection->query('SELECT 1');
}
parent::connect();
+ $this->last_query = "SET datestyle TO 'iso'";
$retval = $this->_connection->exec("SET datestyle TO 'iso'");
if ($retval === false) {
$error = $this->_connection->errorInfo();
protected function _configureConnection()
{
if (!empty($this->_config['encoding'])) {
- $this->_connection->execute('SET client_encoding TO '.$this->quoteString($this->_config['encoding']));
+ $this->last_query = 'SET client_encoding TO '.$this->quoteString($this->_config['encoding']);
+ $this->_connection->execute($this->last_query);
}
if (!empty($this->_config['client_min_messages'])) $this->setClientMinMessages($this->_config['client_min_messages']);
$this->_connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
+ $this->last_query = 'PRAGMA full_column_names=0';
$retval = $this->_connection->exec('PRAGMA full_column_names=0');
if ($retval === false) {
$error = $this->_connection->errorInfo();
throw new Horde_Db_Exception($error[2]);
}
+ $this->last_query = 'PRAGMA short_column_names=1';
$retval = $this->_connection->exec('PRAGMA short_column_names=1');
if ($retval === false) {
$error = $this->_connection->errorInfo();
throw new Horde_Db_Exception($error[2]);
}
+ $this->last_query = 'SELECT sqlite_version(*)';
$this->_sqliteVersion = $this->selectValue('SELECT sqlite_version(*)');
}