]> granicus.if.org Git - php/commitdiff
For named-parameter-to-named-parameter rewrites, we need to map the original
authorWez Furlong <wez@php.net>
Fri, 8 Jul 2005 17:00:28 +0000 (17:00 +0000)
committerWez Furlong <wez@php.net>
Fri, 8 Jul 2005 17:00:28 +0000 (17:00 +0000)
names to the new names.

ext/pdo/pdo_sql_parser.re
ext/pdo/pdo_stmt.c

index dd5ff587f6ed0c9404342d44d568fc0bcd17c8dd..eb3ad88d24933d010e87cb351ba09d6b04a33147 100644 (file)
@@ -285,6 +285,19 @@ rewrite:
                        plc->qlen = strlen(plc->quoted);
                        plc->freeq = 1;
                        newbuffer_len += plc->qlen;
+
+                       if (stmt->named_rewrite_template) {
+                               /* create a mapping */
+                               char *name = estrndup(plc->pos, plc->len);
+                               
+                               if (stmt->bound_param_map == NULL) {
+                                       ALLOC_HASHTABLE(stmt->bound_param_map);
+                                       zend_hash_init(stmt->bound_param_map, 13, NULL, NULL, 0);
+                               }
+
+                               zend_hash_update(stmt->bound_param_map, name, plc->len + 1, idxbuf, plc->qlen + 1, NULL);
+                               efree(name);
+                       }
                }
                                
                goto rewrite;
index 4f765ffa2035595e6298f4b3491746fc36dbfe18..51770d3130d9efff5cb412eb73dc2c5818f5be55 100755 (executable)
@@ -86,6 +86,12 @@ static inline int rewrite_name_to_position(pdo_stmt_t *stmt, struct pdo_bound_pa
                 * driver */
                char *name;
                int position = 0;
+
+               if (stmt->named_rewrite_template) {
+                       /* this is not an error here */
+                       return 1;
+               }
+
                zend_hash_internal_pointer_reset(stmt->bound_param_map);
                while (SUCCESS == zend_hash_get_current_data(stmt->bound_param_map, (void**)&name)) {
                        if (strcmp(name, param->name)) {