We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
生产环境使用php-8.1.2时数字序号占位绑定报错,经排查调整需要在 DbConnection::execute 方法下进行类型转换,并且catch块处理有点问题,PDOException::$errorInfo 只有一个元素。
if ($parameters[0][0] !== ':') { $parameters[0] = intval($parameters[0]); }
完整代码: /** * 执行 * * @param string $query * @param string $parameters * @throws PDOException */ protected function execute($query, $parameters = "") { try { $this->sQuery = @$this->pdo->prepare($query); $this->bindMore($parameters); if (!empty($this->parameters)) { foreach ($this->parameters as $param) { $parameters = explode("\x7F", $param); if ($parameters[0][0] !== ':') { $parameters[0] = intval($parameters[0]); } $this->sQuery->bindParam($parameters[0], $parameters[1]); } } $this->success = $this->sQuery->execute(); } catch (PDOException $e) { // 服务端断开时重连一次 if (isset($e->errorInfo[1]) && ($e->errorInfo[1] == 2006 || $e->errorInfo[1] == 2013)) { $this->closeConnection(); $this->connect();
try { $this->sQuery = $this->pdo->prepare($query); $this->bindMore($parameters); if (!empty($this->parameters)) { foreach ($this->parameters as $param) { $parameters = explode("\x7F", $param); $this->sQuery->bindParam($parameters[0], $parameters[1]); } } $this->success = $this->sQuery->execute(); } catch (PDOException $ex) { $this->rollBackTrans(); throw $ex; } } else { $this->rollBackTrans(); $msg = $e->getMessage(); $err_msg = "SQL:".$this->lastSQL()." ".$msg; $exception = new \PDOException($err_msg, (int)$e->getCode()); throw $exception; } } $this->parameters = array(); }
The text was updated successfully, but these errors were encountered:
这个类不维护了,因为有些老项目还在用所以没后删除。如果你还想用这个Db类可以发个PR我这边合并。
Sorry, something went wrong.
我也是老项目在使用,最近升级PHP后就出问题了,我已经发了PR,
No branches or pull requests
生产环境使用php-8.1.2时数字序号占位绑定报错,经排查调整需要在 DbConnection::execute 方法下进行类型转换,并且catch块处理有点问题,PDOException::$errorInfo 只有一个元素。
if ($parameters[0][0] !== ':') {
$parameters[0] = intval($parameters[0]);
}
完整代码:
/**
* 执行
*
* @param string $query
* @param string $parameters
* @throws PDOException
*/
protected function execute($query, $parameters = "")
{
try {
$this->sQuery = @$this->pdo->prepare($query);
$this->bindMore($parameters);
if (!empty($this->parameters)) {
foreach ($this->parameters as $param) {
$parameters = explode("\x7F", $param);
if ($parameters[0][0] !== ':') {
$parameters[0] = intval($parameters[0]);
}
$this->sQuery->bindParam($parameters[0], $parameters[1]);
}
}
$this->success = $this->sQuery->execute();
} catch (PDOException $e) {
// 服务端断开时重连一次
if (isset($e->errorInfo[1]) && ($e->errorInfo[1] == 2006 || $e->errorInfo[1] == 2013)) {
$this->closeConnection();
$this->connect();
The text was updated successfully, but these errors were encountered: