src/Leevel/Database/Connect.php
public function execute(string $sql, array $bindParams = [])
    {
        $this->initSelect();

        $this->setLastSql($sql, $bindParams);

        if (in_array(($sqlType = $this->normalizeSqlType($sql)), [
            'select',
            'procedure',
        ], true)) {
            throw new InvalidArgumentException(
                'The query method not allows select and procedure SQL statements.'
            );
        }

        $this->pdoStatement = $this->pdo(true)->prepare($sql);

        $this->bindParams($bindParams);

        try {
            $this->pdoStatement->execute();
            $this->reconnectRetry = 0;
        } catch (PDOException $e) {
            if ($this->needReconnect($e)) {
                $this->reconnectRetry++;
                $this->close();

                return self::execute($sql, $bindParams);
            }

            $this->pdoException($e);
        }

        $this->numRows = $this->pdoStatement->rowCount();

        if (in_array($sqlType, [
            'insert',
            'replace',
        ], true)) {
            return $this->lastInsertId();
        }

        return $this->numRows;
    }
public function execute(string $sql, array $bindParams = [])
    {
        $this->initSelect();

        $this->setLastSql($sql, $bindParams);

        if (in_array(($sqlType = $this->normalizeSqlType($sql)), [
            'select',
            'procedure',
        ], true)) {
            throw new InvalidArgumentException(
                'The query method not allows select and procedure SQL statements.'
            );
        }

        $this->pdoStatement = $this->pdo(true)->prepare($sql);

        $this->bindParams($bindParams);

        try {
            $this->pdoStatement->execute();
            $this->reconnectRetry = 0;
        } catch (PDOException $e) {
            if ($this->needReconnect($e)) {
                $this->reconnectRetry++;
                $this->close();

                return self::execute($sql, $bindParams);
            }

            $this->pdoException($e);
        }

        $this->numRows = $this->pdoStatement->rowCount();

        if (in_array($sqlType, [
            'insert',
            'replace',
        ], true)) {
            return $this->lastInsertId();
        }

        return $this->numRows;
    }
执行 sql 语句.

@param string $sql        sql 语句
@param array  $bindParams sql 参数绑定

@return int|string