Per the documentation (
http://php.net/manual/en/pdostatement.debugdumpparams.php),
PDOStatement::debugDumpParams should be emitting the bind parameter value.
Currently however, it does not. Accordingly, attached is a patch for 5.2
(which also applies cleanly to 5.3), which emits the bind parameter value.
While there are quite a few different ways to print and/or get a printable
version of the zval without having to convert the parameter to a string
in-place, I felt that zend_make_printable_zval was the most appropriate.
Feel free to correct me though ;-)
Also, the first example in the documentation is incorrect, as bindValue can
take at most three arguments.
In the example:
$sth->bindValue(':colour', $colour, PDO::PARAM_STR, 12);
should be:
$sth->bindValue(':colour', $colour, PDO::PARAM_STR);
--
Jonah H. Harris, VP of Database Administration
myYearbook.com
diff -cr php5.2-201007201430/ext/pdo/pdo_stmt.c
php5.2-201007201430-pdofix/ext/pdo/pdo_stmt.c
*** php5.2-201007201430/ext/pdo/pdo_stmt.c 2010-06-16 20:41:23.000000000
-0400
--- php5.2-201007201430-pdofix/ext/pdo/pdo_stmt.c 2010-07-20
16:16:46.144446472 -0400
***************
*** 2167,2183 ****
RETURN_FALSE;
}
! php_stream_printf(out TSRMLS_CC, "SQL: [%d] %.*s\n",
stmt->query_stringlen,
stmt->query_stringlen, stmt->query_string);
! php_stream_printf(out TSRMLS_CC, "Params: %d\n",
stmt->bound_params ? zend_hash_num_elements(stmt->bound_params)
: 0);
if (stmt->bound_params) {
zend_hash_internal_pointer_reset_ex(stmt->bound_params, &pos);
while (SUCCESS ==
zend_hash_get_current_data_ex(stmt->bound_params,
(void**)¶m, &pos)) {
char *str;
uint len;
ulong num;
--- 2167,2185 ----
RETURN_FALSE;
}
! php_stream_printf(out TSRMLS_CC, "SQL : [len = %d] %.*s\n",
stmt->query_stringlen,
stmt->query_stringlen, stmt->query_string);
! php_stream_printf(out TSRMLS_CC, "Params: %d\n",
stmt->bound_params ? zend_hash_num_elements(stmt->bound_params)
: 0);
if (stmt->bound_params) {
zend_hash_internal_pointer_reset_ex(stmt->bound_params, &pos);
while (SUCCESS ==
zend_hash_get_current_data_ex(stmt->bound_params,
(void**)¶m, &pos)) {
+ zval param_copy;
+ int use_copy;
char *str;
uint len;
ulong num;
***************
*** 2188,2198 ****
php_stream_printf(out TSRMLS_CC, "Key: Name:
[%d] %.*s\n", len, len, str);
}
! php_stream_printf(out TSRMLS_CC, "paramno=%d\nname=[%d]
\"%.*s\"\nis_param=%d\nparam_type=%d\n",
param->paramno, param->namelen, param->namelen,
param->name ? param->name : "",
param->is_param,
! param->param_type);
zend_hash_move_forward_ex(stmt->bound_params, &pos);
}
}
--- 2190,2214 ----
php_stream_printf(out TSRMLS_CC, "Key: Name:
[%d] %.*s\n", len, len, str);
}
! /*
! * Make the parameter value printable. While there are
a few different
! * ways to do this, this seems simplest for what we
want.
! */
! zend_make_printable_zval(param->parameter, ¶m_copy,
&use_copy);
!
! php_stream_printf(out TSRMLS_CC, "paramno=%d\nname=[%d]
\"%.*s\"\nis_param=%d\nparam_type=%d\nvalue=%s\n",
param->paramno, param->namelen, param->namelen,
param->name ? param->name : "",
param->is_param,
! param->param_type,
! (Z_TYPE_P(param->parameter) == IS_NULL)
! ? "NULL"
! : (use_copy) ? Z_STRVAL_P(¶m_copy)
! :
Z_STRVAL_P(param->parameter));
+ if (use_copy) {
+ zval_dtor(¶m_copy);
+ }
+
zend_hash_move_forward_ex(stmt->bound_params, &pos);
}
}
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php