code: public static function unbufferConnection(Connection $connection)
      {
          /** @var PDOConnection $wrappedConnection */
          $wrappedConnection = $connection->getWrappedConnection();
  
          if (!$wrappedConnection instanceof PDOConnection) {
              throw new InvalidArgumentException('unbufferConection can only be used with pdo_mysql Doctrine driver.');
          }
  
          if ($wrappedConnection->getAttribute(PDO::ATTR_DRIVER_NAME) != 'mysql') {
              throw new InvalidArgumentException(
                  'unbufferConection can only be used with PDO mysql driver, got "' .
                  $wrappedConnection->getAttribute(PDO::ATTR_DRIVER_NAME) . '" instead.'
              );
          }
  
          if ($connection->isConnected()) {
              $connection->close();
          }
  
          $connection->getWrappedConnection()->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
          $connection->connect();
      }
docs: Closes connection if open, opens a unbuffered connection.
  
  @param Connection $connection
  
  @throws InvalidArgumentException