修复多次连接数据库导致事务执行失败的问题

This commit is contained in:
TOP糯米 2020-05-28 21:11:25 +08:00
parent 8da633a984
commit 10ec74c2f7
1 changed files with 5 additions and 2 deletions

View File

@ -121,7 +121,7 @@ class Database
*/ */
public static function table($table, $pk = '', $prefix = '') public static function table($table, $pk = '', $prefix = '')
{ {
$ident = md5($prefix . $table); $ident = $prefix . $table;
if (!isset(self::$instance[$ident])) { if (!isset(self::$instance[$ident])) {
self::$instance[$ident] = new self($table, $pk, $prefix); self::$instance[$ident] = new self($table, $pk, $prefix);
} }
@ -136,7 +136,10 @@ class Database
*/ */
private function setDriver(DatabaseIfs $driver, $config) private function setDriver(DatabaseIfs $driver, $config)
{ {
self::$driver = $driver->connect($config); if (!self::$driver) {
self::$driver = $driver->connect($config);
}
return self::$driver;
} }
/** /**