core/Mysql.php
public function execute(string $sql, $args = null)
    {
        $sql = str_replace('@pf_', $this->prefix, $sql);
        if ($args !== null && !is_array($args)) {
            $args = [$args];
        }
        $time = 0;
        if (defined('DEBUG_MYSQL_LOG') && DEBUG_MYSQL_LOG) {
            $time = microtime(true);
        }
        try {
            $retry = 0;
            redo:
            $sth = $this->pdo->prepare($sql);
            $ret = false;
            try {
                $ret = $sth->execute($args);
            } catch (\Exception $exception) {
                $ret = false;
            }
            if ($ret === FALSE) {
                $err = $sth->errorInfo();
                if (isset($err[1]) && $err[1] == 2006) {
                    $this->reconnection();
                    if ($retry == 0) {
                        $retry = 1;
                        goto redo;
                    }
                }
                $this->_lastSql = Mysql::format($sql, $args);
                if (isset($err[2])) {
                    throw new MysqlException('execute sql statement error:' . $err[0] . ',' . $err[1] . ',' . $err[2], $this->_lastSql);
                } else {
                    throw new MysqlException('execute sql statement error:', $this->_lastSql);
                }
            }
            if (defined('DEBUG_MYSQL_LOG') && DEBUG_MYSQL_LOG) {
                $this->_lastSql = Mysql::format($sql, $args);
                Logger::info($this->_lastSql, microtime(true) - $time);
            }
            return $sth;
        } catch (\Exception $exception) {
            $this->_lastSql = Mysql::format($sql, $args);
            if (defined('DEBUG_MYSQL_LOG') && DEBUG_MYSQL_LOG) {
                Logger::info($this->_lastSql, microtime(true) - $time);
            }
            throw new MysqlException($exception->getMessage(), $this->_lastSql, $exception->getCode(), $exception);
        }
    }
public function execute(string $sql, $args = null)
    {
        $sql = str_replace('@pf_', $this->prefix, $sql);
        if ($args !== null && !is_array($args)) {
            $args = [$args];
        }
        $time = 0;
        if (defined('DEBUG_MYSQL_LOG') && DEBUG_MYSQL_LOG) {
            $time = microtime(true);
        }
        try {
            $retry = 0;
            redo:
            $sth = $this->pdo->prepare($sql);
            $ret = false;
            try {
                $ret = $sth->execute($args);
            } catch (\Exception $exception) {
                $ret = false;
            }
            if ($ret === FALSE) {
                $err = $sth->errorInfo();
                if (isset($err[1]) && $err[1] == 2006) {
                    $this->reconnection();
                    if ($retry == 0) {
                        $retry = 1;
                        goto redo;
                    }
                }
                $this->_lastSql = Mysql::format($sql, $args);
                if (isset($err[2])) {
                    throw new MysqlException('execute sql statement error:' . $err[0] . ',' . $err[1] . ',' . $err[2], $this->_lastSql);
                } else {
                    throw new MysqlException('execute sql statement error:', $this->_lastSql);
                }
            }
            if (defined('DEBUG_MYSQL_LOG') && DEBUG_MYSQL_LOG) {
                $this->_lastSql = Mysql::format($sql, $args);
                Logger::info($this->_lastSql, microtime(true) - $time);
            }
            return $sth;
        } catch (\Exception $exception) {
            $this->_lastSql = Mysql::format($sql, $args);
            if (defined('DEBUG_MYSQL_LOG') && DEBUG_MYSQL_LOG) {
                Logger::info($this->_lastSql, microtime(true) - $time);
            }
            throw new MysqlException($exception->getMessage(), $this->_lastSql, $exception->getCode(), $exception);
        }
    }
执行sql 语句
@param string $sql
@param null $args
@return bool|\PDOStatement
@throws MysqlException