]> granicus.if.org Git - php/commitdiff
- Fixed some code to be working with unicode
authorFelipe Pena <felipe@php.net>
Wed, 25 Mar 2009 12:05:51 +0000 (12:05 +0000)
committerFelipe Pena <felipe@php.net>
Wed, 25 Mar 2009 12:05:51 +0000 (12:05 +0000)
ext/pdo/pdo_dbh.c
ext/pdo/pdo_stmt.c

index 4e90eeb1f4ae80edb7de31da83a9de68a07adb04..14159297499aebd8975b5492b8cf69a9cdbb2d9e 100755 (executable)
@@ -1033,9 +1033,9 @@ static PHP_METHOD(PDO, errorInfo)
        array_init(return_value);
 
        if (dbh->query_stmt) {
-               add_next_index_string(return_value, dbh->query_stmt->error_code, 1);
+               add_next_index_ascii_string(return_value, dbh->query_stmt->error_code, 1);
        } else {
-               add_next_index_string(return_value, dbh->error_code, 1);
+               add_next_index_ascii_string(return_value, dbh->error_code, 1);
        }
 
        if (dbh->methods->fetch_err) {
@@ -1265,7 +1265,6 @@ int pdo_hash_methods(pdo_dbh_t *dbh, int kind TSRMLS_DC)
        const zend_function_entry *funcs;
        zend_function func;
        zend_internal_function *ifunc = (zend_internal_function*)&func;
-       int namelen;
        char *lc_name;
 
        if (!dbh || !dbh->methods || !dbh->methods->get_driver_methods) {
@@ -1282,9 +1281,12 @@ int pdo_hash_methods(pdo_dbh_t *dbh, int kind TSRMLS_DC)
        zend_hash_init_ex(dbh->cls_methods[kind], 8, NULL, NULL, dbh->is_persistent, 0);
 
        while (funcs->fname) {
+               int namelen = strlen(funcs->fname)+1;
+               
                ifunc->type = ZEND_INTERNAL_FUNCTION;
                ifunc->handler = funcs->handler;
-               pdo_zstr_sval(ifunc->function_name) = (char*)funcs->fname;
+               ifunc->function_name.u = malloc(UBYTES(namelen));
+               u_charsToUChars(funcs->fname, ifunc->function_name.u, namelen);
                ifunc->scope = dbh->ce;
                ifunc->prototype = NULL;
                if (funcs->arg_info) {
@@ -1309,10 +1311,9 @@ int pdo_hash_methods(pdo_dbh_t *dbh, int kind TSRMLS_DC)
                } else {
                        ifunc->fn_flags = ZEND_ACC_PUBLIC;
                }
-               namelen = strlen(funcs->fname);
                lc_name = emalloc(namelen+1);
                zend_str_tolower_copy(lc_name, funcs->fname, namelen);
-               zend_hash_add(dbh->cls_methods[kind], lc_name, namelen+1, &func, sizeof(func), NULL);
+               zend_ascii_hash_add(dbh->cls_methods[kind], lc_name, namelen+1, &func, sizeof(zend_function), NULL);
                efree(lc_name);
                funcs++;
        }
@@ -1365,7 +1366,7 @@ static union _zend_function *dbh_method_get(
        }
 
 out:
-       if (std_object_handlers.get_method) {
+       if (!fbc && std_object_handlers.get_method) {
                fbc = std_object_handlers.get_method(object_pp, method_name, method_len TSRMLS_CC);
        }
 
index 1d559977651b8622ff993173dfa1e7dbb3c4b68a..92e705ca3b0cb34b14a68ca31035a7b36d17a336 100755 (executable)
@@ -1537,12 +1537,12 @@ static PHP_METHOD(PDOStatement, fetchAll)
                        /* no break */
                case 2:
                        stmt->fetch.cls.ctor_args = ctor_args; /* we're not going to free these */
-                       if (Z_TYPE_P(arg2) != IS_STRING) {
+                       if (Z_TYPE_P(arg2) != IS_STRING && Z_TYPE_P(arg2) != IS_UNICODE) {
                                pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "Invalid class name (should be a string)" TSRMLS_CC);
                                error = 1;
                                break;
                        } else {
-                               stmt->fetch.cls.ce = zend_fetch_class(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
+                               stmt->fetch.cls.ce = zend_u_fetch_class(Z_TYPE_P(arg2), Z_UNIVAL_P(arg2), Z_UNILEN_P(arg2), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
                                if (!stmt->fetch.cls.ce) {
                                        pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not find user-specified class" TSRMLS_CC);
                                        error = 1;
@@ -2746,9 +2746,11 @@ static int row_call_method(
 static union _zend_function *row_get_ctor(zval *object TSRMLS_DC)
 {
        static zend_internal_function ctor = {0};
+       int namelen = sizeof("__construct");
 
        ctor.type = ZEND_INTERNAL_FUNCTION;
-       pdo_zstr_sval(ctor.function_name) = "__construct";
+       ctor.function_name.u = malloc(UBYTES(namelen));
+       u_charsToUChars("__construct", ctor.function_name.u, namelen);  
 
        ctor.scope = pdo_row_ce;
        ctor.handler = ZEND_FN(dbstmt_constructor);