adeynes / cucumber

Moderation plugin for PocketMine-MP
GNU General Public License v2.0
29 stars 11 forks source link

Add custom port on DB #40

Closed Lycol50 closed 2 years ago

Lycol50 commented 3 years ago

its is supported, by libasynql without modifying src files.

Lycol50 commented 3 years ago

up

JohnB17 commented 3 years ago

This shouldn't be needed, you can just add the port to the end of the host.

Lycol50 commented 2 years ago

This shouldn't be needed, you can just add the port to the end of the host.

A Snippet from libasynql/MysqlCredentials.php, it defaults itself to port 3306, when $array["port"] is NULL

/**
     * Creates a new {@link MysqlCredentials} instance from an array (e.g. from Config), with the following defaults:
     * <pre>
     * host: 127.0.0.1
     * username: root
     * password: ""
     * schema: {$defaultSchema}
     * port: 3306
     * socket: ""
     * </pre>
     *
     * @param array       $array
     * @param string|null $defaultSchema default null
     * @return MysqlCredentials
     * @throws ConfigException If <code>schema</code> is missing and <code>$defaultSchema</code> is null/not passed
     */
    public static function fromArray(array $array, ?string $defaultSchema = null) : MysqlCredentials{
        if(!isset($defaultSchema, $array["schema"])){
            throw new ConfigException("The attribute \"schema\" is missing in the MySQL settings");
        }
        return new MysqlCredentials($array["host"] ?? "127.0.0.1", $array["username"] ?? "root",
            $array["password"] ?? "", $array["schema"] ?? $defaultSchema, $array["port"] ?? 3306, $array["socket"] ?? "");
    }

Assuming 2151 is your port number, Therefore, using X.X.X.X:2151 will not work, because without port parameter on config, it defaults itself to 3306.