mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 14:16:39 +02:00
DibiConnection: deprecated inTransaction (BC break!)
This commit is contained in:
@@ -584,7 +584,7 @@ class dibi
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public static function datetime($time = NULL)
|
public static function datetime($time = NULL)
|
||||||
{
|
{
|
||||||
@@ -594,7 +594,7 @@ class dibi
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public static function date($date = NULL)
|
public static function date($date = NULL)
|
||||||
{
|
{
|
||||||
|
@@ -40,9 +40,6 @@ class DibiConnection extends DibiObject
|
|||||||
/** @var bool Is connected? */
|
/** @var bool Is connected? */
|
||||||
private $connected = FALSE;
|
private $connected = FALSE;
|
||||||
|
|
||||||
/** @var bool Is in transaction? */
|
|
||||||
private $inTxn = FALSE;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -153,9 +150,6 @@ class DibiConnection extends DibiObject
|
|||||||
final public function disconnect()
|
final public function disconnect()
|
||||||
{
|
{
|
||||||
if ($this->connected) {
|
if ($this->connected) {
|
||||||
if ($this->inTxn) {
|
|
||||||
$this->rollback();
|
|
||||||
}
|
|
||||||
$this->driver->disconnect();
|
$this->driver->disconnect();
|
||||||
$this->connected = FALSE;
|
$this->connected = FALSE;
|
||||||
}
|
}
|
||||||
@@ -418,18 +412,10 @@ class DibiConnection extends DibiObject
|
|||||||
public function begin($savepoint = NULL)
|
public function begin($savepoint = NULL)
|
||||||
{
|
{
|
||||||
$this->connect();
|
$this->connect();
|
||||||
if (!$savepoint && $this->inTxn) {
|
|
||||||
throw new DibiException('There is already an active transaction.');
|
|
||||||
}
|
|
||||||
if ($this->profiler !== NULL) {
|
if ($this->profiler !== NULL) {
|
||||||
$ticket = $this->profiler->before($this, IDibiProfiler::BEGIN, $savepoint);
|
$ticket = $this->profiler->before($this, IDibiProfiler::BEGIN, $savepoint);
|
||||||
}
|
}
|
||||||
if ($savepoint && !$this->inTxn) {
|
|
||||||
$this->driver->begin();
|
|
||||||
}
|
|
||||||
$this->driver->begin($savepoint);
|
$this->driver->begin($savepoint);
|
||||||
|
|
||||||
$this->inTxn = TRUE;
|
|
||||||
if (isset($ticket)) {
|
if (isset($ticket)) {
|
||||||
$this->profiler->after($ticket);
|
$this->profiler->after($ticket);
|
||||||
}
|
}
|
||||||
@@ -444,14 +430,10 @@ class DibiConnection extends DibiObject
|
|||||||
*/
|
*/
|
||||||
public function commit($savepoint = NULL)
|
public function commit($savepoint = NULL)
|
||||||
{
|
{
|
||||||
if (!$this->inTxn) {
|
|
||||||
throw new DibiException('There is no active transaction.');
|
|
||||||
}
|
|
||||||
if ($this->profiler !== NULL) {
|
if ($this->profiler !== NULL) {
|
||||||
$ticket = $this->profiler->before($this, IDibiProfiler::COMMIT, $savepoint);
|
$ticket = $this->profiler->before($this, IDibiProfiler::COMMIT, $savepoint);
|
||||||
}
|
}
|
||||||
$this->driver->commit($savepoint);
|
$this->driver->commit($savepoint);
|
||||||
$this->inTxn = (bool) $savepoint;
|
|
||||||
if (isset($ticket)) {
|
if (isset($ticket)) {
|
||||||
$this->profiler->after($ticket);
|
$this->profiler->after($ticket);
|
||||||
}
|
}
|
||||||
@@ -466,14 +448,10 @@ class DibiConnection extends DibiObject
|
|||||||
*/
|
*/
|
||||||
public function rollback($savepoint = NULL)
|
public function rollback($savepoint = NULL)
|
||||||
{
|
{
|
||||||
if (!$this->inTxn) {
|
|
||||||
throw new DibiException('There is no active transaction.');
|
|
||||||
}
|
|
||||||
if ($this->profiler !== NULL) {
|
if ($this->profiler !== NULL) {
|
||||||
$ticket = $this->profiler->before($this, IDibiProfiler::ROLLBACK, $savepoint);
|
$ticket = $this->profiler->before($this, IDibiProfiler::ROLLBACK, $savepoint);
|
||||||
}
|
}
|
||||||
$this->driver->rollback($savepoint);
|
$this->driver->rollback($savepoint);
|
||||||
$this->inTxn = (bool) $savepoint;
|
|
||||||
if (isset($ticket)) {
|
if (isset($ticket)) {
|
||||||
$this->profiler->after($ticket);
|
$this->profiler->after($ticket);
|
||||||
}
|
}
|
||||||
@@ -482,12 +460,11 @@ class DibiConnection extends DibiObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is in transaction?
|
* @deprecated
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function inTransaction()
|
public function inTransaction()
|
||||||
{
|
{
|
||||||
return $this->inTxn;
|
trigger_error('Deprecated: use "SELECT @@autocommit" query instead.', E_USER_WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -429,7 +429,7 @@ final class DibiTranslator extends DibiObject
|
|||||||
} elseif ($value instanceof DateTime) {
|
} elseif ($value instanceof DateTime) {
|
||||||
return $this->driver->escape($value, dibi::DATETIME);
|
return $this->driver->escape($value, dibi::DATETIME);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->hasError = TRUE;
|
$this->hasError = TRUE;
|
||||||
return '**Unexpected ' . gettype($value) . '**';
|
return '**Unexpected ' . gettype($value) . '**';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user