改进主从读取

This commit is contained in:
thinkphp
2018-04-25 15:01:48 +08:00
parent 0ad7586556
commit 4003537d84
3 changed files with 19 additions and 9 deletions

View File

@@ -451,24 +451,24 @@ abstract class Connection
$this->debug(false);
if ($query && !empty($this->config['deploy']) && !empty($this->config['read_master'])) {
$query->setModelReadMaster(true);
$query->readMaster(true);
}
$this->numRows = $this->PDOStatement->rowCount();
return $this->numRows;
} catch (\PDOException $e) {
if ($this->isBreak($e)) {
return $this->close()->execute($sql, $bind);
return $this->close()->execute($sql, $bind, $query);
}
throw new PDOException($e, $this->config, $this->getLastsql());
} catch (\Throwable $e) {
if ($this->isBreak($e)) {
return $this->close()->execute($sql, $bind);
return $this->close()->execute($sql, $bind, $query);
}
throw $e;
} catch (\Exception $e) {
if ($this->isBreak($e)) {
return $this->close()->execute($sql, $bind);
return $this->close()->execute($sql, $bind, $query);
}
throw $e;
}