1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace KIF\Db;
- use KIF\Exception\ParamsException;
- use KIF\Db\MySQLi;
- use KIF\Core\Config;
- class Transaction {
-
- protected $db;
- public function __construct($cluster_flag = 'default') {
- $appConfig = Config::getInstance()->current();
- $dbConfig = $appConfig['db'];
-
- if (!$dbConfig || !isset($dbConfig[$cluster_flag]) || !is_string($dbConfig[$cluster_flag])) {
- throw new ParamsException("load config error:{$dbConfig}");
- }
-
- $this->db = new MySQLi($dbConfig[$cluster_flag]);
- }
-
- public function start() {
- return $this->db->startTransaction();
- }
-
- public function commit($strTransactionId) {
- return $this->db->commit($strTransactionId);
- }
-
- public function rollback($strTransactionId) {
- return $this->db->rollback($strTransactionId);
- }
-
- public function beginUseMaster() {
- return $this->db->beginUseMaster();
- }
-
- public function restore($strMasterStatusId) {
- return $this->db->restore($strMasterStatusId);
- }
- }
|