| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace common\replaces;
- use yii\db\Transaction;
- /**
- * 兼容mycat的操作
- * @Author bing
- * @DateTime 2021-10-14 10:42:07
- * @copyright: Copyright (c) 2020 广东七件事集团
- */
- class Connection extends \yii\db\Connection
- {
- /**
- * @var array An array of [[setQueryBuilder()]] calls, holding the passed arguments.
- * Is used to restore a QueryBuilder configuration after the connection close/open cycle.
- *
- * @see restoreQueryBuilderConfiguration()
- */
- private $_queryBuilderConfigurations = [];
- /**
- * @var Transaction the currently active transaction
- */
- private $_transaction;
- /**
- * @var Schema the database schema
- */
- private $_schema;
- /**
- * @var string driver name
- */
- private $_driverName;
- /**
- * @var Connection|false the currently active master connection
- */
- private $_master = false;
- /**
- * @var Connection|false the currently active slave connection
- */
- private $_slave = false;
- /**
- * @var array query cache parameters for the [[cache()]] calls
- */
- private $_queryCacheInfo = [];
- /**
- * @var string[] quoted table name cache for [[quoteTableName()]] calls
- */
- private $_quotedTableNames;
- /**
- * @var string[] quoted column name cache for [[quoteColumnName()]] calls
- */
- private $_quotedColumnNames;
- /**
- * Starts a transaction.
- * @param string|null $isolationLevel The isolation level to use for this transaction.
- * See [[Transaction::begin()]] for details.
- * @return Transaction the transaction initiated
- */
- public function beginTransaction($isolationLevel = null)
- {
- $this->open();
- if (($transaction = $this->getTransaction()) === null) {
- $transaction = $this->_transaction = new Transaction(['db' => $this]);
- $transaction->begin($isolationLevel);
- }
- return $transaction;
- }
- public function getTransaction()
- {
- return $this->_transaction && $this->_transaction->getIsActive() ? $this->_transaction : null;
- }
- }
|