Skip to content

Commit

Permalink
DibiConnection: deprecated inTransaction (BC break!)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 17, 2009
1 parent f6d4107 commit 20d22dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 28 deletions.
4 changes: 2 additions & 2 deletions dibi/dibi.php
Expand Up @@ -584,7 +584,7 @@ public static function delete($table)


/**
* @deprecated
* @deprecated
*/
public static function datetime($time = NULL)
{
Expand All @@ -594,7 +594,7 @@ public static function datetime($time = NULL)


/**
* @deprecated
* @deprecated
*/
public static function date($date = NULL)
{
Expand Down
27 changes: 2 additions & 25 deletions dibi/libs/DibiConnection.php
Expand Up @@ -40,9 +40,6 @@ class DibiConnection extends DibiObject
/** @var bool Is connected? */
private $connected = FALSE;

/** @var bool Is in transaction? */
private $inTxn = FALSE;



/**
Expand Down Expand Up @@ -153,9 +150,6 @@ final protected function connect()
final public function disconnect()
{
if ($this->connected) {
if ($this->inTxn) {
$this->rollback();
}
$this->driver->disconnect();
$this->connected = FALSE;
}
Expand Down Expand Up @@ -418,18 +412,10 @@ public function insertId($sequence = NULL)
public function begin($savepoint = NULL)
{
$this->connect();
if (!$savepoint && $this->inTxn) {
throw new DibiException('There is already an active transaction.');
}
if ($this->profiler !== NULL) {
$ticket = $this->profiler->before($this, IDibiProfiler::BEGIN, $savepoint);
}
if ($savepoint && !$this->inTxn) {
$this->driver->begin();
}
$this->driver->begin($savepoint);

$this->inTxn = TRUE;
if (isset($ticket)) {
$this->profiler->after($ticket);
}
Expand All @@ -444,14 +430,10 @@ public function begin($savepoint = NULL)
*/
public function commit($savepoint = NULL)
{
if (!$this->inTxn) {
throw new DibiException('There is no active transaction.');
}
if ($this->profiler !== NULL) {
$ticket = $this->profiler->before($this, IDibiProfiler::COMMIT, $savepoint);
}
$this->driver->commit($savepoint);
$this->inTxn = (bool) $savepoint;
if (isset($ticket)) {
$this->profiler->after($ticket);
}
Expand All @@ -466,14 +448,10 @@ public function commit($savepoint = NULL)
*/
public function rollback($savepoint = NULL)
{
if (!$this->inTxn) {
throw new DibiException('There is no active transaction.');
}
if ($this->profiler !== NULL) {
$ticket = $this->profiler->before($this, IDibiProfiler::ROLLBACK, $savepoint);
}
$this->driver->rollback($savepoint);
$this->inTxn = (bool) $savepoint;
if (isset($ticket)) {
$this->profiler->after($ticket);
}
Expand All @@ -482,12 +460,11 @@ public function rollback($savepoint = NULL)


/**
* Is in transaction?
* @return bool
* @deprecated
*/
public function inTransaction()
{
return $this->inTxn;
trigger_error('Deprecated: use "SELECT @@autocommit" query instead.', E_USER_WARNING);
}


Expand Down
2 changes: 1 addition & 1 deletion dibi/libs/DibiTranslator.php
Expand Up @@ -429,7 +429,7 @@ public function formatValue($value, $modifier)
} elseif ($value instanceof DateTime) {
return $this->driver->escape($value, dibi::DATETIME);

} else {
} else {
$this->hasError = TRUE;
return '**Unexpected ' . gettype($value) . '**';
}
Expand Down

0 comments on commit 20d22dd

Please sign in to comment.