From: Wez Furlong Date: Mon, 18 Jul 2005 14:46:55 +0000 (+0000) Subject: make a start on a debugging function. X-Git-Tag: RELEASE_0_9~87 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=be88f5a960f3a1dfb82504aca240ddb20f2c1c0d;p=php make a start on a debugging function. --- diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 1c316d25a3..eb97860d68 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -1776,6 +1776,48 @@ static PHP_METHOD(PDOStatement, closeCursor) } /* }}} */ +/* {{{ proto void PDOStatement::debugDumpParams() + A utility for internals hackers to debug parameter internals */ +static PHP_METHOD(PDOStatement, debugDumpParams) +{ + pdo_stmt_t *stmt = (pdo_stmt_t*)zend_object_store_get_object(getThis() TSRMLS_CC); + php_stream *out = php_stream_open_wrapper("php://output", "w", 0, NULL); + HashPosition pos; + struct pdo_bound_param_data *param; + + 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; + + if (zend_hash_get_current_key_ex(stmt->bound_params, &str, &len, &num, 0, &pos) == HASH_KEY_IS_STRING) { + php_stream_printf(out TSRMLS_CC, "Key: Position #%d:\n", num); + } else { + 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->is_param, + param->param_type); + + } + } + + php_stream_close(out); +} +/* }}} */ + function_entry pdo_dbstmt_functions[] = { PHP_ME(PDOStatement, execute, NULL, ZEND_ACC_PUBLIC) @@ -1795,6 +1837,7 @@ function_entry pdo_dbstmt_functions[] = { PHP_ME(PDOStatement, setFetchMode, NULL, ZEND_ACC_PUBLIC) PHP_ME(PDOStatement, nextRowset, NULL, ZEND_ACC_PUBLIC) PHP_ME(PDOStatement, closeCursor, NULL, ZEND_ACC_PUBLIC) + PHP_ME(PDOStatement, debugDumpParams, NULL, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} };