summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2008-11-05 23:40:38 (GMT)
committerFelipe Pena <felipe@php.net>2008-11-05 23:40:38 (GMT)
commita912d80adbeee5526b7748c154c18953daf4d88f (patch)
treed0f3b760b6010aeb45142cb62e2da09e5a6c3a46
parentbc569c56a66613325a85d5f062097010c87f8c5e (diff)
downloadphp-a912d80adbeee5526b7748c154c18953daf4d88f.tar.gz
MFH:
- Fixed wrong check - Improved test
-rwxr-xr-xext/pdo/pdo_stmt.c8
-rw-r--r--ext/pdo_sqlite/tests/debugdumpparams_001.phpt20
2 files changed, 17 insertions, 11 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 058d876..27cb65c 100755
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -2197,14 +2197,14 @@ static PHP_METHOD(PDOStatement, debugDumpParams)
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);
+ if (zend_hash_get_current_key_ex(stmt->bound_params, &str, &len, &num, 0, &pos) == HASH_KEY_IS_LONG) {
+ php_stream_printf(out TSRMLS_CC, "Key: Position #%ld:\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,
+ 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);
diff --git a/ext/pdo_sqlite/tests/debugdumpparams_001.phpt b/ext/pdo_sqlite/tests/debugdumpparams_001.phpt
index d85784a..c263eb1 100644
--- a/ext/pdo_sqlite/tests/debugdumpparams_001.phpt
+++ b/ext/pdo_sqlite/tests/debugdumpparams_001.phpt
@@ -9,23 +9,29 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
$db = new pdo('sqlite:memory');
-$x= $db->prepare('select :a, :b');
+$x= $db->prepare('select :a, :b, ?');
$x->bindValue(':a', 1, PDO::PARAM_INT);
$x->bindValue(':b', 'foo');
+$x->bindValue(3, 1313);
var_dump($x->debugDumpParams());
?>
--EXPECT--
-SQL: [13] select :a, :b
-Params: 2
-Key: Position #0:
+SQL: [16] select :a, :b, ?
+Params: 3
+Key: Name: [2] :a
paramno=-1
-name=[2] :a
+name=[2] ":a"
is_param=1
param_type=1
-Key: Position #0:
+Key: Name: [2] :b
paramno=-1
-name=[2] :b
+name=[2] ":b"
+is_param=1
+param_type=2
+Key: Position #2:
+paramno=2
+name=[0] ""
is_param=1
param_type=2
NULL