summaryrefslogtreecommitdiff
path: root/ext/mysql/php_mysql.c
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2001-11-22 07:58:37 +0000
committerDerick Rethans <derick@php.net>2001-11-22 07:58:37 +0000
commit2d6842b103764fd564e836c5c34e1f08b659ab93 (patch)
tree8fca9a8442adc4ac5d30dba872601d750c814799 /ext/mysql/php_mysql.c
parent3eded520eff5529f53e2c6edf8e1e75e2f7ece34 (diff)
downloadphp-git-2d6842b103764fd564e836c5c34e1f08b659ab93.tar.gz
- Added a parameter to mysql_connect to force a new database link to be
created. (patch by Markus Fischer <mfischer@guru.josefine.at>) @- Added a parameter to mysql_connect to force a new database link to be @ created. (Markus, Derick)
Diffstat (limited to 'ext/mysql/php_mysql.c')
-rw-r--r--ext/mysql/php_mysql.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index 5963624ae6..60f1307bd0 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -431,8 +431,8 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
int hashed_details_length, port = MYSQL_PORT;
php_mysql_conn *mysql=NULL;
void (*handler) (int);
- zval **z_host=NULL, **z_user=NULL, **z_passwd=NULL;
- zend_bool free_host=0;
+ zval **z_host=NULL, **z_user=NULL, **z_passwd=NULL, **z_new_link=NULL;
+ zend_bool free_host=0, new_link=0;
socket = MySG(default_socket);
@@ -477,6 +477,17 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
passwd = Z_STRVAL_PP(z_passwd);
}
break;
+ case 4: {
+ if (zend_get_parameters_ex(4, &z_host, &z_user, &z_passwd, &z_new_link) == FAILURE) {
+ MYSQL_DO_CONNECT_RETURN_FALSE();
+ }
+ convert_to_string_ex(z_user);
+ convert_to_string_ex(z_passwd);
+ user = Z_STRVAL_PP(z_user);
+ passwd = Z_STRVAL_PP(z_passwd);
+ new_link = Z_BVAL_PP(z_new_link);
+ }
+ break;
default:
WRONG_PARAM_COUNT;
break;
@@ -532,7 +543,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
list_entry *le;
/* try to find if we already have this link in our persistent list */
- if (zend_hash_find(&EG(persistent_list), hashed_details, hashed_details_length+1, (void **) &le)==FAILURE) { /* we don't */
+ if (new_link || zend_hash_find(&EG(persistent_list), hashed_details, hashed_details_length+1, (void **) &le)==FAILURE) { /* we don't */
list_entry new_le;
if (MySG(max_links)!=-1 && MySG(num_links)>=MySG(max_links)) {
@@ -612,7 +623,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
* if it doesn't, open a new mysql link, add it to the resource list,
* and add a pointer to it with hashed_details as the key.
*/
- if (zend_hash_find(&EG(regular_list), hashed_details, hashed_details_length+1,(void **) &index_ptr)==SUCCESS) {
+ if (!new_link && zend_hash_find(&EG(regular_list), hashed_details, hashed_details_length+1,(void **) &index_ptr)==SUCCESS) {
int type, link;
void *ptr;