src/Db/Command.php
public function setConnection($connection = null)
    {
        if ($connection instanceof TransactionInterface) {
            $connection = $connection->getConnection();
        }
        $this->connection = $connection;
        if ($connection instanceof EventEmitterWildcardInterface) {
            //Remove connection instance on close
            $this->connection->once(ConnectionInterface::EVENT_CLOSE, function() use ($connection) {
                if ($this->connection === $connection) {
                    $this->connection = null;
                }
            });
        }
        return $this;
    }
public function setConnection($connection = null)
    {
        if ($connection instanceof TransactionInterface) {
            $connection = $connection->getConnection();
        }
        $this->connection = $connection;
        if ($connection instanceof EventEmitterWildcardInterface) {
            //Remove connection instance on close
            $this->connection->once(ConnectionInterface::EVENT_CLOSE, function() use ($connection) {
                if ($this->connection === $connection) {
                    $this->connection = null;
                }
            });
        }
        return $this;
    }
Set connection to use with
@param ConnectionInterface|TransactionInterface|null $connection
@return $this this command instance