|
|
|
@ -449,7 +449,7 @@ class Connection extends Component
|
|
|
|
|
* Use 0 to indicate that the cached data will never expire. |
|
|
|
|
* @param \yii\caching\Dependency $dependency the cache dependency associated with the cached query results. |
|
|
|
|
* @return mixed the return result of the callable |
|
|
|
|
* @throws \Exception|\Throwable if there is any exception during query |
|
|
|
|
* @throws \Throwable if there is any exception during query |
|
|
|
|
* @see enableQueryCache |
|
|
|
|
* @see queryCache |
|
|
|
|
* @see noCache() |
|
|
|
@ -461,9 +461,6 @@ class Connection extends Component
|
|
|
|
|
$result = call_user_func($callable, $this); |
|
|
|
|
array_pop($this->_queryCacheInfo); |
|
|
|
|
return $result; |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
array_pop($this->_queryCacheInfo); |
|
|
|
|
throw $e; |
|
|
|
|
} catch (\Throwable $e) { |
|
|
|
|
array_pop($this->_queryCacheInfo); |
|
|
|
|
throw $e; |
|
|
|
@ -489,7 +486,7 @@ class Connection extends Component
|
|
|
|
|
* @param callable $callable a PHP callable that contains DB queries which should not use query cache. |
|
|
|
|
* The signature of the callable is `function (Connection $db)`. |
|
|
|
|
* @return mixed the return result of the callable |
|
|
|
|
* @throws \Exception|\Throwable if there is any exception during query |
|
|
|
|
* @throws \Throwable if there is any exception during query |
|
|
|
|
* @see enableQueryCache |
|
|
|
|
* @see queryCache |
|
|
|
|
* @see cache() |
|
|
|
@ -501,9 +498,6 @@ class Connection extends Component
|
|
|
|
|
$result = call_user_func($callable, $this); |
|
|
|
|
array_pop($this->_queryCacheInfo); |
|
|
|
|
return $result; |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
array_pop($this->_queryCacheInfo); |
|
|
|
|
throw $e; |
|
|
|
|
} catch (\Throwable $e) { |
|
|
|
|
array_pop($this->_queryCacheInfo); |
|
|
|
|
throw $e; |
|
|
|
@ -715,7 +709,7 @@ class Connection extends Component
|
|
|
|
|
* @param callable $callback a valid PHP callback that performs the job. Accepts connection instance as parameter. |
|
|
|
|
* @param string|null $isolationLevel The isolation level to use for this transaction. |
|
|
|
|
* See [[Transaction::begin()]] for details. |
|
|
|
|
* @throws \Exception|\Throwable if there is any exception during query. In this case the transaction will be rolled back. |
|
|
|
|
* @throws \Throwable if there is any exception during query. In this case the transaction will be rolled back. |
|
|
|
|
* @return mixed result of callback function |
|
|
|
|
*/ |
|
|
|
|
public function transaction(callable $callback, $isolationLevel = null) |
|
|
|
@ -728,9 +722,6 @@ class Connection extends Component
|
|
|
|
|
if ($transaction->isActive && $transaction->level === $level) { |
|
|
|
|
$transaction->commit(); |
|
|
|
|
} |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
$this->rollbackTransactionOnLevel($transaction, $level); |
|
|
|
|
throw $e; |
|
|
|
|
} catch (\Throwable $e) { |
|
|
|
|
$this->rollbackTransactionOnLevel($transaction, $level); |
|
|
|
|
throw $e; |
|
|
|
@ -981,7 +972,7 @@ class Connection extends Component
|
|
|
|
|
* @param callable $callback a PHP callable to be executed by this method. Its signature is |
|
|
|
|
* `function (Connection $db)`. Its return value will be returned by this method. |
|
|
|
|
* @return mixed the return value of the callback |
|
|
|
|
* @throws \Exception|\Throwable if there is any exception thrown from the callback |
|
|
|
|
* @throws \Throwable if there is any exception thrown from the callback |
|
|
|
|
*/ |
|
|
|
|
public function useMaster(callable $callback) |
|
|
|
|
{ |
|
|
|
@ -989,9 +980,6 @@ class Connection extends Component
|
|
|
|
|
$this->enableSlaves = false; |
|
|
|
|
try { |
|
|
|
|
$result = call_user_func($callback, $this); |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
$this->enableSlaves = true; |
|
|
|
|
throw $e; |
|
|
|
|
} catch (\Throwable $e) { |
|
|
|
|
$this->enableSlaves = true; |
|
|
|
|
throw $e; |
|
|
|
|