Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PHP-DEV] PDO/MySQL connect broken for remote hosts

22 views
Skip to first unread message

Timm Friebe

unread,
Feb 18, 2005, 7:49:44 AM2/18/05
to
Hi,
has anyone noticed PDO/MySQL will always try to connect locally
regardless of what I put in the host=... DSN part?

The statement:
new PDO('mysql:host=php3.de', '****', '*******');

will only throw a PDOException:

Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through
socket '/tmp/mysql.sock' (2)' in /usr/home/thekid/pdo.php:2

This here fixes it:

Index: ext/pdo_mysql/mysql_driver.c
===================================================================
RCS file: /repository/php-src/ext/pdo_mysql/mysql_driver.c,v
retrieving revision 1.36
diff -u -r1.36 mysql_driver.c
--- ext/pdo_mysql/mysql_driver.c 13 Feb 2005 17:16:24 -0000
1.36
+++ ext/pdo_mysql/mysql_driver.c 18 Feb 2005 10:00:31 -0000
@@ -327,6 +327,7 @@
if (vars[2].optval && !strcmp("localhost", vars[2].optval)) {
unix_socket = vars[4].optval;
} else {
+ host = vars[2].optval;
port = atoi(vars[3].optval);
}
dbname = vars[1].optval;

--
Timm
If it ain't broken, it doesn't have enough features yet

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Wez Furlong

unread,
Feb 18, 2005, 10:12:00 AM2/18/05
to
Thanks; committed.

--Wez.

0 new messages