Make the database command

@param $connection
@param $connectionName
@return array
545436
protected function makeCommand($connection, $connectionName)
    {
        $cmd[] = 'mysqldump -u ' . $connection['username'];
        $cmd[] = '--password=' . $connection['password'];
        $cmd[] = $connection['database'];
        $cmd[] = ' -h ' . $connection['host'];
        if ( ! empty($connection['port'])) {
            $cmd[] = '-P ' . $connection['port'];
        }
        $cmd[] = '> ' . $this->filename($connectionName);
        return implode(' ', $cmd);
    }
386161
protected function createCommand($connection, $queue, ListenerOptions $options)
    {
        return array_filter([
            $this->phpBinary(),
            $this->artisanBinary(),
            'queue:work',
            $connection,
            '--once',
            "--queue={$queue}",
            "--delay={$options->delay}",
            "--memory={$options->memory}",
            "--sleep={$options->sleep}",
            "--tries={$options->maxTries}",
        ], function ($value) {
            return ! is_null($value);
        });
    }
375940
protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
    {
        if ($this->container->bound($key = "db.connection.{$driver}")) {
            return $this->container->make($key, [$connection, $database, $prefix, $config]);
        }

        switch ($driver) {
            case 'mysql':
                return new MySqlConnection($connection, $database, $prefix, $config);

            case 'pgsql':
                return new PostgresConnection($connection, $database, $prefix, $config);
        }

        return parent::createConnection($driver, $connection, $database, $prefix, $config);
    }
848671
public static function createFromConnection(Connection $connection)
    {
        $driver = $connection->getDriver()->getName();

        if ($driver === 'pdo_sqlite') {
            return new ConnectionHandler\SqliteConnectionHandler($connection);
        }

        if ($driver === 'pdo_pgsql') {
            return new ConnectionHandler\PostgresConnectionHandler($connection);
        }

        return new self($connection);
    }
260483
public function getTableForeignKeys($tableName = null, $connectionName = null)
    {
        $tableName = $this->validateTableName($tableName);

        return $this->getSchema($connectionName)->listTableForeignKeys($tableName);
    }
1009301
public function searchDatabase(
        Connection $connection,
        string $databaseName,
        string $searchTerm
    ): \Generator {
        $databaseMetadata = (new MetadataFactory())->getDatabaseMetadata($connection, $databaseName);

        foreach ($databaseMetadata->getAllTableMetadata() as $tableMetadata) {
            $resultList = $this->searchTable(
                $connection,
                $tableMetadata->getDatabaseName(),
                $tableMetadata->getTableName(),
                $searchTerm
            );

            foreach ($resultList as $result) {
                yield $result;
            }
        }
    }
246158
public function createTable($tablename, $connection = NULL)
    {
        $connection = DatabaseQuery::connect();
        try
        {
            $sqlQuery = self::sanitizeQuery($tablename);
            $query = $connection->prepare($sqlQuery);
            if($query->execute())
            {
                return true;
            }
        }catch(PDOException $e){
            return $e->getMessage();
        }
    }
1190736
public function makeRaw(string $connectionName = ''): RawQueryBuilder
    {
        $connection = $this->provideConnection($connectionName);
        $statementBuilder = new RawStatementBuider;
        return new RawQueryBuilder($connection, $statementBuilder);
    }
136616
public function getConnectionCredentials($connectionName)
    {
        $user = $this->bash->runLocally('whoami');

        $usesPrivateKey = $this->command->confirm('Do you use an SSH key to connect to it?');
        $questions = $usesPrivateKey ? [
            'key' => ['Where can I find your key?', $this->paths->getDefaultKeyPath()],
            'keyphrase' => 'If it needs a passphrase enter it',
            'host' => 'Where is your server located? <comment>(eg. foobar.com)</comment>',
            'username' => ['What is the username for it?', $user],
            'root_directory' => ['Where do you want your application deployed?', '/home/www/'],
        ] : [
            'host' => 'Where is your server located?',
            'username' => ['What is the username for it?', $user],
            'password' => 'And password?',
            'root_directory' => ['Where do you want your application deployed?', '/home/www/'],
        ];

        $this->connections[$connectionName] = $this->askQuestions($connectionName, $questions);
    }
788572
public function addQuery($query, $connectionName = 'default')
    {
        $queryData = [
            $query['time'] / 1000,
            $query['query'],
            $query['bindings']
        ];
        $this->queriesByConnection[$connectionName][] = $queryData;
        if (!isset($this->totalQueriesTimeByConnection[$connectionName])) {
            $this->totalQueriesTimeByConnection[$connectionName] = 0;
        }
        $this->totalQueriesTimeByConnection[$connectionName] += $query['time'] / 1000;
        return $this;
    }
89844
public static function getConnection($connectionName = '')
    {
        if (!$connectionName) {
            $connectionName = static::$defaultConnection;
        }
        if (isset(static::$connections[$connectionName])) {
            return static::$connections[$connectionName];
        }
    }
536905
final public static function getDbInstance(string $databaseName = '#none'):\PDO
    {
        if (self::$co_instance == null) {
            new self($databaseName);
        }
        return (self::$co_instance);
    }
231892
public function make(Connection $connection, $name = null)
    {
        if ($name && $this->config->has('migrations.' . $name)) {
            $config = new Repository($this->config->get('migrations.' . $name, []));
        } else {
            $config = new Repository($this->config->get('migrations.default', []));
        }

        $configuration = new Configuration($connection);
        $configuration->setName($config->get('name', 'Doctrine Migrations'));
        $configuration->setMigrationsNamespace($config->get('namespace', 'Database\\Migrations'));
        $configuration->setMigrationsTableName($config->get('table', 'migrations'));

        $configuration->getConnection()->getConfiguration()->setFilterSchemaAssetsExpression(
            $config->get('schema.filter', '/^(?).*$/')
        );

        $configuration->setNamingStrategy($this->container->make(
            $config->get('naming_strategy', DefaultNamingStrategy::class)
        ));

        $configuration->setMigrationsFinder($configuration->getNamingStrategy()->getFinder());

        $directory = $config->get('directory', database_path('migrations'));
        $configuration->setMigrationsDirectory($directory);
        $configuration->registerMigrationsFromDirectory($directory);

        return $configuration;
    }
462049
public function getTableColumns($tableName = null, $connectionName = null)
    {
        $tableName = $this->validateTableName($tableName);

        return $this->getSchema($connectionName)->listTableColumns($tableName);
    }
476036
public function getServerMetadata(
        Connection $connection
    ) {
        // Attempt to list databases, ignoring internal databases
        try {
            $statement = $connection->query('SHOW DATABASES WHERE `Database` NOT IN ("information_schema", "performance_schema", "sys", "mysql");');
        } catch (\Throwable $e) {
            throw new \RuntimeException('Failed to list databases: ' . $e->getMessage());
        }

        $databaseMetadataList = [];
        /** @var string $databaseName */
        while ($databaseName = $statement->fetchColumn(0)) {
            $databaseMetadataList[] = $this->getDatabaseMetadata($connection, $databaseName);
        }

        return new ServerMetadata($connection->getHost(), $databaseMetadataList);
    }
56681
public function getConnection($connection, $server = null)
    {
        $connectionKey = $this->credentials->sanitizeConnection($connection, $server);
        $handle = $connectionKey->toHandle();

        $connections = $this->getConnections();
        if (!$connections->has($handle)) {
            throw new ConnectionException('Invalid connection: '.$handle);
        }

        return $connections[$handle];
    }
68730
public function dropDatabase($connectionName)
    {
        $configuration = $this->getConfiguration($connectionName);
        $database = $this->getConnection($connectionName);

        $database->DBDelete(
            $configuration->getDatabase()
        );
    }