|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-06-06 22:30 UTC] awe at email dot cz
[2001-06-26 08:53 UTC] joey@php.net
[2001-06-26 17:05 UTC] joey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 12:00:01 2025 UTC |
function sybase_connect doesn't accept fourth parameter, charset. Following patch solves the problem. Martin Nedbal --- php-4.0.5/ext/sybase_ct/php_sybase_ct.c Sun Mar 11 05:13:53 2001 +++ php-4.0.5_sybase_ct_charset_path/ext/sybase_ct/php_sybase_ct.c Wed Jun 6 15:29:42 2001 @@ -375,6 +375,8 @@ -static int php_sybase_do_connect_internal(sybase_link *sybase, char *host, char *user, char *passwd) +static int php_sybase_do_connect_internal(sybase_link *sybase, char *host, char *user, char *passwd, char *charset) { +CS_LOCALE *tmp_locale; + SybCtLS_FETCH(); @@ -398,4 +400,26 @@ ct_con_props(sybase->connection, CS_SET, CS_PASSWORD, passwd, CS_NULLTERM, NULL); } + if (charset) { + // charset + if (cs_loc_alloc(SybCtG(context), &tmp_locale)!=CS_SUCCEED) { + php_error(E_WARNING,"Sybase: Unable to allocate locale information."); + } + else { + if (cs_locale(SybCtG(context), CS_SET, tmp_locale, CS_LC_ALL, NULL, CS_NULLTERM, NULL)!=CS_SUCCEED) { + php_error(E_WARNING,"Sybase: Unable to load default locale data."); + } else { + if (cs_locale(SybCtG(context), CS_SET, tmp_locale, CS_SYB_CHARSET, charset, CS_NULLTERM, NULL)!=CS_SUCCEED) { + php_error(E_WARNING,"Sybase: Unable to update character set."); + } else { + if (ct_con_props(sybase->connection, CS_SET, CS_LOC_PROP, tmp_locale, CS_UNUSED, NULL)!=CS_SUCCEED) { + php_error(E_WARNING,"Sybase: Unable to update connection properties."); + } + } + } + } +// ct_con_props(sybase->connection, CS_SET, CS_CHARSETCNV, CS_TRUE, CS_NULLTERM, NULL); +// ct_con_props(sybase->connection, CS_SET, CS_CHARSETCNV, charset, CS_NULLTERM, NULL); + } + ct_con_props(sybase->connection, CS_SET, CS_APPNAME, SybCtG(appname), CS_NULLTERM, NULL); @@ -427,5 +451,5 @@ 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; @@ -435,5 +459,5 @@ switch(ZEND_NUM_ARGS()) { case 0: /* defaults */ - host=user=passwd=NULL; + host=user=passwd=charset=NULL; hashed_details_length=6+3; hashed_details = (char *) emalloc(hashed_details_length+1); @@ -487,4 +511,25 @@ } 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; @@ -515,5 +560,5 @@ sybase_ptr = (sybase_link *) malloc(sizeof(sybase_link)); - if (!php_sybase_do_connect_internal(sybase_ptr, host, user, passwd)) { + if (!php_sybase_do_connect_internal(sybase_ptr, host, user, passwd, charset)) { free(sybase_ptr); efree(hashed_details); @@ -569,5 +614,5 @@ */ memcpy(&sybase, sybase_ptr, sizeof(sybase_link)); - if (!php_sybase_do_connect_internal(sybase_ptr, host, user, passwd)) { + if (!php_sybase_do_connect_internal(sybase_ptr, host, user, passwd, charset)) { memcpy(sybase_ptr, &sybase, sizeof(sybase_link)); efree(hashed_details); @@ -612,5 +657,5 @@ sybase_ptr = (sybase_link *) emalloc(sizeof(sybase_link)); - if (!php_sybase_do_connect_internal(sybase_ptr, host, user, passwd)) { + if (!php_sybase_do_connect_internal(sybase_ptr, host, user, passwd, charset)) { efree(sybase_ptr); efree(hashed_details);