php-telegram-bot / core

PHP Telegram Bot based on the official Telegram Bot API
MIT License
3.86k stars 951 forks source link

Support MySQL port in DSN #857

Closed bojardo closed 6 years ago

bojardo commented 6 years ago

Please, add support for MySQL port in PDO DSN. It will be very helpful with non-standard installations (for example, I use an Amazon RDS and I can not use standard MySQL port, so as a workaround I add ';port=NNN' to the 'host' key of $mysql_credentials).

hook:php :

$mysql_credentials = [ 'host' => 'localhost', 'port' => 12345, // add this line 'user' => 'dbuser', 'password' => 'dbpass', 'database' => 'dbname', ];

longman/telegram-bot/src/Telegram.php , function enableMySQL:

-- $dsn = 'mysql:host=' . $credentials['host'] . ';dbname=' . $credentials['database']; ++ $dsn = 'mysql:host=' . $credentials['host'] . ';port=' . $credentials['port'] . ';dbname=' . $credentials['database'];

Thank you and compliments, great lib! :)

jacklul commented 6 years ago

You can also pass a custom PDO instance with enableExternalMysql().

akalongman commented 6 years ago

Thank you for feedback, we will add port soon

noplanman commented 6 years ago

@bojardo This has been added to 0.54.0 :tada:

So you can update and use it.