From: Wez Furlong Date: Fri, 8 Jul 2005 17:00:28 +0000 (+0000) Subject: For named-parameter-to-named-parameter rewrites, we need to map the original X-Git-Tag: php-5.1.0b3~87 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=38a02b62446cdb60037f67eb0f2b5c4d8c3039a6;p=php For named-parameter-to-named-parameter rewrites, we need to map the original names to the new names. --- diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index dd5ff587f6..eb3ad88d24 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -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; diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 4f765ffa20..51770d3130 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -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)) {