]> granicus.if.org Git - php/commitdiff
- Fixed wrong check
authorFelipe Pena <felipe@php.net>
Wed, 5 Nov 2008 23:39:09 +0000 (23:39 +0000)
committerFelipe Pena <felipe@php.net>
Wed, 5 Nov 2008 23:39:09 +0000 (23:39 +0000)
- Improved test

ext/pdo/pdo_stmt.c
ext/pdo_sqlite/tests/debugdumpparams_001.phpt

index e8dd0f70e9eaf41b9ac0b1f4e8b138c334249a43..4aa6fbde9359671745189bbd5077664485d986f8 100755 (executable)
@@ -2200,14 +2200,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);
                        
index d85784a4f1558c774a954eeb6ff25256411221fb..c263eb143b1b6f3ee42e02f3b8a4170c4f0e1edc 100644 (file)
@@ -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