diff options
author | Rasmus Lerdorf <rasmus@php.net> | 1999-12-02 19:09:01 +0000 |
---|---|---|
committer | Rasmus Lerdorf <rasmus@php.net> | 1999-12-02 19:09:01 +0000 |
commit | 67f4cfe1aa33785ba1f3f929982ad413917009df (patch) | |
tree | 8966d079dc481f3ef0d47cfd90976c9088761e24 /ext/mysql/php_mysql.c | |
parent | fdcaba4096ad391ad6633e3d84a757e4eb3d5a70 (diff) | |
download | php-git-67f4cfe1aa33785ba1f3f929982ad413917009df.tar.gz |
@ Add optional socket path to the mysql_?connect() functions
Diffstat (limited to 'ext/mysql/php_mysql.c')
-rw-r--r-- | ext/mysql/php_mysql.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index a9344cae12..3d9b5e7982 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -368,7 +368,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) #if APACHE void (*handler) (int); #endif - char *user,*passwd,*host,*tmp; + char *user,*passwd,*host,*socket=NULL,*tmp; char *hashed_details; int hashed_details_length,port; MYSQL *mysql; @@ -443,7 +443,11 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) if (host && (tmp=strchr(host,':'))) { *tmp=0; tmp++; - port = atoi(tmp); + if (tmp[0] != '/') { + port = atoi(tmp); + } else { + socket = tmp; + } } else { port = MySG(default_port); } @@ -476,7 +480,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) mysql = (MYSQL *) malloc(sizeof(MYSQL)); #if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */ mysql_init(mysql); - if (mysql_real_connect(mysql,host,user,passwd,NULL,port,NULL,0)==NULL) { + if (mysql_real_connect(mysql,host,user,passwd,NULL,port,socket,0)==NULL) { #else if (mysql_connect(mysql,host,user,passwd)==NULL) { #endif @@ -514,7 +518,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) signal(SIGPIPE,handler); #endif #if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */ - if (mysql_real_connect(le->ptr,host,user,passwd,NULL,port,NULL,0)==NULL) { + if (mysql_real_connect(le->ptr,host,user,passwd,NULL,port,socket,0)==NULL) { #else if (mysql_connect(le->ptr,host,user,passwd)==NULL) { #endif @@ -605,7 +609,7 @@ static int php_mysql_get_default_link(INTERNAL_FUNCTION_PARAMETERS MySLS_DC) } -/* {{{ proto int mysql_connect([string hostname[:port]] [, string username] [, string password]) +/* {{{ proto int mysql_connect([string hostname[:port][:/path/to/socket]] [, string username] [, string password]) Open a connection to a MySQL Server */ PHP_FUNCTION(mysql_connect) { @@ -614,7 +618,7 @@ PHP_FUNCTION(mysql_connect) /* }}} */ -/* {{{ proto int mysql_pconnect([string hostname[:port]] [, string username] [, string password]) +/* {{{ proto int mysql_pconnect([string hostname[:port][:/path/to/socket]] [, string username] [, string password]) Open a persistent connection to a MySQL Server */ PHP_FUNCTION(mysql_pconnect) { |