cvs: /php4/ext/mysql php_mysql.c
| From: | Rasmus Lerdorf | Date: | Thu, 02 Dec 1999 19:09:32 +0000 |
| Subject: | cvs: /php4/ext/mysql php_mysql.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-7262@lists.php.net to get a copy of this message | ||
rasmus Thu Dec 2 14:09:32 1999 EDT
Modified files:
/php4/ext/mysql php_mysql.c
Log:
@ Add optional socket path to the mysql_?connect() functions
Index: php4/ext/mysql/php_mysql.c
diff -u php4/ext/mysql/php_mysql.c:1.9 php4/ext/mysql/php_mysql.c:1.10
--- php4/ext/mysql/php_mysql.c:1.9 Wed Dec 1 18:14:54 1999
+++ php4/ext/mysql/php_mysql.c Thu Dec 2 14:09:01 1999
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mysql.c,v 1.9 1999/12/01 23:14:54 ssb Exp $ */
+/* $Id: php_mysql.c,v 1.10 1999/12/02 19:09:01 rasmus Exp $ */
/* TODO:
@@ -368,7 +368,7 @@
#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 @@
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 @@
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 @@
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 @@
}
-/* {{{ 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 @@
/* }}} */
-/* {{{ 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)
{