wez Mon Jul 11 23:19:44 2005 EDT Modified files: /php-src/ext/pdo pdo_stmt.c pdo_sql_parser.re Log: remember ? -> :pdox mapping so that binds by position can be mapped to names if required. http://cvs.php.net/diff.php/php-src/ext/pdo/pdo_stmt.c?r1=1.110&r2=1.111&ty=u Index: php-src/ext/pdo/pdo_stmt.c diff -u php-src/ext/pdo/pdo_stmt.c:1.110 php-src/ext/pdo/pdo_stmt.c:1.111 --- php-src/ext/pdo/pdo_stmt.c:1.110 Mon Jul 11 22:40:59 2005 +++ php-src/ext/pdo/pdo_stmt.c Mon Jul 11 23:19:44 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_stmt.c,v 1.110 2005/07/12 02:40:59 wez Exp $ */ +/* $Id: pdo_stmt.c,v 1.111 2005/07/12 03:19:44 wez Exp $ */ /* The PDO Statement Handle Class */ @@ -92,7 +92,14 @@ return 1; } if (!param->name) { - return 1; + /* do the reverse; map the parameter number to the name */ + if (SUCCESS == zend_hash_index_find(stmt->bound_param_map, param->paramno, (void**)&name)) { + param->name = estrdup(name); + param->namelen = strlen(param->name); + return 1; + } + pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined" TSRMLS_CC); + return 0; } zend_hash_internal_pointer_reset(stmt->bound_param_map); http://cvs.php.net/diff.php/php-src/ext/pdo/pdo_sql_parser.re?r1=1.25&r2=1.26&ty=u Index: php-src/ext/pdo/pdo_sql_parser.re diff -u php-src/ext/pdo/pdo_sql_parser.re:1.25 php-src/ext/pdo/pdo_sql_parser.re:1.26 --- php-src/ext/pdo/pdo_sql_parser.re:1.25 Fri Jul 8 16:35:41 2005 +++ php-src/ext/pdo/pdo_sql_parser.re Mon Jul 11 23:19:44 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_sql_parser.re,v 1.25 2005/07/08 20:35:41 helly Exp $ */ +/* $Id: pdo_sql_parser.re,v 1.26 2005/07/12 03:19:44 wez Exp $ */ #include "php.h" #include "php_pdo_driver.h" @@ -276,9 +276,15 @@ /* rewrite ? to :pdoX */ char idxbuf[32]; const char *tmpl = stmt->named_rewrite_template ? stmt->named_rewrite_template : ":pdo%d"; + char *name; newbuffer_len = inquery_len; + if (stmt->bound_param_map == NULL) { + ALLOC_HASHTABLE(stmt->bound_param_map); + zend_hash_init(stmt->bound_param_map, 13, NULL, NULL, 0); + } + for (plc = placeholders; plc; plc = plc->next) { snprintf(idxbuf, sizeof(idxbuf), tmpl, plc->bindno + 1); plc->quoted = estrdup(idxbuf); @@ -286,18 +292,18 @@ plc->freeq = 1; newbuffer_len += plc->qlen; + name = estrndup(plc->pos, plc->len); + 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); } + + /* map number to name */ + zend_hash_index_update(stmt->bound_param_map, plc->bindno, idxbuf, plc->qlen + 1, NULL); + + efree(name); } goto rewrite;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php