diff options
author | Timm Friebe <thekid@php.net> | 2008-11-10 10:59:44 +0000 |
---|---|---|
committer | Timm Friebe <thekid@php.net> | 2008-11-10 10:59:44 +0000 |
commit | 12abaadf8455a562cdf31f54aab3883261422961 (patch) | |
tree | 860a529ec1c504aa22a7abc23c04582f794db754 | |
parent | eb2e561bfe5579e561b90ecec037a3fd2e962c71 (diff) | |
download | php-git-12abaadf8455a562cdf31f54aab3883261422961.tar.gz |
- Added optional parameter "new" to sybase_connect
# [DOC] If a second call is made to sybase_connect() with the same arguments
# no new link will be established, but instead, the link identifier of the
# already opened link will be returned. The new parameter modifies this
# behavior and makes sybase_connect() always open a new link, even if
# sybase_connect() was called before with the same parameters.
-rw-r--r-- | ext/sybase_ct/php_sybase_ct.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/ext/sybase_ct/php_sybase_ct.c b/ext/sybase_ct/php_sybase_ct.c index 2c6d64bfcf..3b0e35f82e 100644 --- a/ext/sybase_ct/php_sybase_ct.c +++ b/ext/sybase_ct/php_sybase_ct.c @@ -49,6 +49,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_sybase_connect, 0, 0, 0) ZEND_ARG_INFO(0, password) ZEND_ARG_INFO(0, charset) ZEND_ARG_INFO(0, appname) + ZEND_ARG_INFO(0, new) ZEND_END_ARG_INFO() static @@ -753,13 +754,19 @@ static void php_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) { char *user, *passwd, *host, *charset, *appname; char *hashed_details; - int hashed_details_length; - int len; + int hashed_details_length, len; + zend_bool new = 0; sybase_link *sybase_ptr; host= user= passwd= charset= appname= NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sssss", &host, &len, &user, &len, &passwd, &len, &charset, &len, &appname, &len) == FAILURE) { - return; + if (persistent) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!s!s!", &host, &len, &user, &len, &passwd, &len, &charset, &len, &appname, &len) == FAILURE) { + return; + } + } else { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!s!s!b", &host, &len, &user, &len, &passwd, &len, &charset, &len, &appname, &len, &new) == FAILURE) { + return; + } } hashed_details_length = spprintf( &hashed_details, @@ -865,7 +872,7 @@ static void php_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) * if it doesn't, open a new sybase 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 && zend_hash_find(&EG(regular_list), hashed_details, hashed_details_length+1, (void **) &index_ptr)==SUCCESS) { int type, link; void *ptr; @@ -929,7 +936,7 @@ static int php_sybase_get_default_link(INTERNAL_FUNCTION_PARAMETERS) } -/* {{{ proto int sybase_connect([string host [, string user [, string password [, string charset [, string appname]]]]]) +/* {{{ proto int sybase_connect([string host [, string user [, string password [, string charset [, string appname [, bool new]]]]]]) Open Sybase server connection */ PHP_FUNCTION(sybase_connect) { |