This commit is contained in:
2023-04-02 23:23:55 +08:00
parent f1faeb038f
commit cd9327f5c2
2 changed files with 284 additions and 278 deletions
+3 -6
View File
@@ -145,7 +145,7 @@ class Connection extends Component
* @return PDO * @return PDO
* @throws Exception * @throws Exception
*/ */
public function getMasterClient(): PDO public function getMasterClient(): Mysql\PDO
{ {
return $this->connection->get([ return $this->connection->get([
'cds' => $this->cds, 'cds' => $this->cds,
@@ -163,7 +163,7 @@ class Connection extends Component
* @return PDO * @return PDO
* @throws Exception * @throws Exception
*/ */
public function getSlaveClient(): PDO public function getSlaveClient(): Mysql\PDO
{ {
return $this->getMasterClient(); return $this->getMasterClient();
} }
@@ -185,14 +185,11 @@ class Connection extends Component
* @return PDO * @return PDO
* @throws Exception * @throws Exception
*/ */
public function getPdo(bool $restore = false): PDO public function getPdo(bool $restore = false): Mysql\PDO
{ {
if ($restore === true) { if ($restore === true) {
return Context::setContext($this->cds, $this->getMasterClient()); return Context::setContext($this->cds, $this->getMasterClient());
} }
if (!Db::inTransactionsActive()) {
return $this->getMasterClient();
}
if (!Context::hasContext($this->cds)) { if (!Context::hasContext($this->cds)) {
return Context::setContext($this->cds, $this->getMasterClient()); return Context::setContext($this->cds, $this->getMasterClient());
} else { } else {
+10 -1
View File
@@ -192,7 +192,7 @@ class PDO implements StopHeartbeatCheck
* @return int * @return int
* @throws Exception * @throws Exception
*/ */
public function count(string $sql, array $params = []): int public function rowCount(string $sql, array $params = []): int
{ {
$pdo = $this->queryPrev($sql, $params); $pdo = $this->queryPrev($sql, $params);
@@ -313,6 +313,15 @@ class PDO implements StopHeartbeatCheck
} }
/**
* @return array
*/
public function errorInfo(): array
{
return $this->pdo->errorInfo();
}
/** /**
* @return \PDO * @return \PDO
*/ */