]> granicus.if.org Git - php/commitdiff
Add 4th optional parameter to sybase_[p]connect to specify the charset
authorRasmus Lerdorf <rasmus@php.net>
Mon, 7 Aug 2000 00:15:39 +0000 (00:15 +0000)
committerRasmus Lerdorf <rasmus@php.net>
Mon, 7 Aug 2000 00:15:39 +0000 (00:15 +0000)
for the connection
@- Add 4th optional parameter to sybase_[p]connect to specify the charset
@  for the connection (alf@alpha.ulatina.ac.cr)

ext/sybase/php_sybase_db.c

index dccf78090da93ca4db7adb1f426fcee144161126..3ed1106b309cf17eef58f3c1809e0e6a557407e1 100644 (file)
@@ -254,7 +254,7 @@ PHP_RSHUTDOWN_FUNCTION(sybase)
 
 static void php_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
 {
-       char *user,*passwd,*host;
+       char *user,*passwd,*host,*charset;
        char *hashed_details;
        int hashed_details_length;
        sybase_link sybase,*sybase_ptr;
@@ -313,6 +313,25 @@ static void php_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
                                sprintf(hashed_details,"sybase_%s_%s_%s",yyhost->value.str.val,yyuser->value.str.val,yypasswd->value.str.val); /* SAFE */
                        }
                        break;
+               case 4: {
+                               pval *yyhost,*yyuser,*yypasswd,*yycharset;
+
+                               if (getParameters(ht, 4, &yyhost, &yyuser, &yypasswd, &yycharset) == FAILURE) {
+                                       RETURN_FALSE;
+                               }
+                               convert_to_string(yyhost);
+                               convert_to_string(yyuser);
+                               convert_to_string(yypasswd);
+                               convert_to_string(yycharset);
+                               host = yyhost->value.str.val;
+                               user = yyuser->value.str.val;
+                               passwd = yypasswd->value.str.val;
+                               charset = yycharset->value.str.val;
+                               hashed_details_length = yyhost->value.str.len+yyuser->value.str.len+yypasswd->value.str.len+yycharset->value.str.len+6+3;
+                               hashed_details = (char *) emalloc(hashed_details_length+1);
+                               sprintf(hashed_details,"sybase_%s_%s_%s_%s",yyhost->value.str.val,yyuser->value.str.val,yypasswd->value.str.val,yycharset->value.str.val); /* SAFE */
+                       }
+                       break;
                default:
                        WRONG_PARAM_COUNT;
                        break;
@@ -331,6 +350,9 @@ static void php_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
        if (passwd) {
                DBSETLPWD(sybase.login,passwd);
        }
+       if (charset) {
+               DBSETLCHARSET(sybase.login,charset);
+       }
        DBSETLAPP(sybase.login,php_sybase_module.appname);
        sybase.valid = 1;
 
@@ -483,7 +505,7 @@ static int php_sybase_get_default_link(INTERNAL_FUNCTION_PARAMETERS)
 }
 
 
-/* {{{ proto int sybase_connect([string host [, string user [, string password]]])
+/* {{{ proto int sybase_connect([string host [, string user [, string password [, string charset]]]])
    Open Sybase server connection */
 PHP_FUNCTION(sybase_connect)
 {
@@ -491,7 +513,7 @@ PHP_FUNCTION(sybase_connect)
 }
 /* }}} */
 
-/* {{{ proto int sybase_pconnect([string host [, string user [, string password]]])
+/* {{{ proto int sybase_pconnect([string host [, string user [, string password [, string charset]]]])
    Open persistent Sybase connection */
 PHP_FUNCTION(sybase_pconnect)
 {