struct placeholder *next;
};
+static void free_param_name(zval *el) {
+ efree(Z_PTR_P(el));
+}
+
PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len,
char **outquery, int *outquery_len TSRMLS_DC)
{
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_init(stmt->bound_param_map, 13, NULL, free_param_name, 0);
}
for (plc = placeholders; plc; plc = plc->next) {
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_init(stmt->bound_param_map, 13, NULL, free_param_name, 0);
}
for (plc = placeholders; plc; plc = plc->next) {
char *name;
-
name = estrndup(plc->pos, plc->len);
zend_hash_index_update_mem(stmt->bound_param_map, plc->bindno, name, plc->len + 1);
efree(name);
struct placeholder *next;
};
+static void free_param_name(zval *el) {
+ efree(Z_PTR_P(el));
+}
+
PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len,
char **outquery, int *outquery_len TSRMLS_DC)
{
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_init(stmt->bound_param_map, 13, NULL, free_param_name, 0);
}
for (plc = placeholders; plc; plc = plc->next) {
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_init(stmt->bound_param_map, 13, NULL, free_param_name, 0);
}
for (plc = placeholders; plc; plc = plc->next) {
char *name;
-
name = estrndup(plc->pos, plc->len);
zend_hash_index_update_mem(stmt->bound_param_map, plc->bindno, name, plc->len + 1);
efree(name);
* we will raise an error, as we can't be sure that it is safe
* to bind multiple parameters onto the same zval in the underlying
* driver */
- zval *name;
+ char *name;
int position = 0;
if (stmt->named_rewrite_template) {
}
if (!param->name) {
/* do the reverse; map the parameter number to the name */
- if ((name = zend_hash_index_find(stmt->bound_param_map, param->paramno)) != NULL) {
- param->name = STR_COPY(Z_STR_P(name));
+ if ((name = zend_hash_index_find_ptr(stmt->bound_param_map, param->paramno)) != NULL) {
+ param->name = STR_INIT(name, strlen(name), 0);
return 1;
}
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined" TSRMLS_CC);
return 0;
}
- ZEND_HASH_FOREACH_VAL(stmt->bound_param_map, name) {
- if (strncmp(Z_STRVAL_P(name), param->name->val, param->name->len + 1)) {
+ ZEND_HASH_FOREACH_PTR(stmt->bound_param_map, name) {
+ if (strncmp(name, param->name->val, param->name->len + 1)) {
position++;
continue;
}
if (key) {
/* yes this is correct. we don't want to count the null byte. ask wez */
- param.name = STR_COPY(key);
+ param.name = key;
param.paramno = -1;
} else {
/* we're okay to be zero based here */
/* ensure that we free any previous unfetched results */
#ifndef PDO_USE_MYSQLND
if (S->stmt) {
- stmt->column_count = (int)mysql_num_fields(S->result);
+ //???? This line is very suspicious
+ //stmt->column_count = (int)mysql_num_fields(S->result);
mysql_stmt_free_result(S->stmt);
}
#endif