CraftCli\Command\DbPullCommand::makeMysqlCommand PHP Method

makeMysqlCommand() protected method

Make a MysqlCommand object
protected makeMysqlCommand ( string $class, array $credentials, string $query = null ) : CraftCli\Support\AbstractMysqlCommand
$class string
$credentials array
$query string
return CraftCli\Support\AbstractMysqlCommand
    protected function makeMysqlCommand($class, $credentials, $query = null)
    {
        $mysqlCommand = new $class($credentials['database']);
        if (!empty($credentials['server'])) {
            $mysqlCommand->host = $credentials['server'];
        }
        if (!empty($credentials['user'])) {
            $mysqlCommand->user = $credentials['user'];
        }
        if (!empty($credentials['password'])) {
            $mysqlCommand->password = $credentials['password'];
        }
        if (!empty($credentials['port'])) {
            $mysqlCommand->port = $credentials['port'];
        }
        if ($query) {
            $mysqlCommand->query = $query;
        }
        return $mysqlCommand;
    }