summaryrefslogtreecommitdiff
path: root/ext/pdo
diff options
context:
space:
mode:
authorBishop Bettini <bishop@php.net>2016-06-21 08:16:51 -0400
committerJulien Pauli <jpauli@php.net>2016-07-12 10:47:07 +0200
commit15336b44d95c41079438af8ac73f77ff893aeef7 (patch)
treec72630aa4d215826759a715f58db9a81d95b08f6 /ext/pdo
parent403f23b4607cfcaa97279217a64b0b38f15a7bb5 (diff)
downloadphp-git-15336b44d95c41079438af8ac73f77ff893aeef7.tar.gz
Fixes #52384: Adds parameter value to dumped output. Also adds output flag indicating presence of PDO::PARAM_INPUT_OUTPUT.
Diffstat (limited to 'ext/pdo')
-rw-r--r--ext/pdo/pdo_stmt.c30
-rw-r--r--ext/pdo/tests/bug_52384.phpt81
2 files changed, 109 insertions, 2 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index a2ae2fdf3a..2c089f1da6 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -2159,10 +2159,36 @@ static PHP_METHOD(PDOStatement, debugDumpParams)
php_stream_printf(out TSRMLS_CC, "Key: Name: [%d] %.*s\n", len, len, str);
}
- php_stream_printf(out TSRMLS_CC, "paramno=%ld\nname=[%d] \"%.*s\"\nis_param=%d\nparam_type=%d\n",
+ php_stream_printf(out TSRMLS_CC, "paramno=%ld\nname=[%d] \"%.*s\"\nis_param=%d\nparam_type=%d\nis_input_output=%d\n",
param->paramno, param->namelen, param->namelen, param->name ? param->name : "",
param->is_param,
- param->param_type);
+ PDO_PARAM_TYPE(param->param_type),
+ (param->param_type & PDO_PARAM_INPUT_OUTPUT) == PDO_PARAM_INPUT_OUTPUT);
+
+ /*
+ * Check the type of the parameter and print out the value.
+ *
+ * Most are self explanatory with the following exceptions:
+ * PDO::PARAM_INT evaluates to a long
+ * PDO::PARAM_LOB evaluates to a string
+ */
+ switch (Z_TYPE_P(param->parameter)) {
+ case IS_BOOL:
+ php_stream_printf(out TSRMLS_CC, "param_value=%s\n", Z_BVAL_P(param->parameter)?"true":"false");
+ break;
+ case IS_NULL:
+ php_stream_printf(out TSRMLS_CC, "param_value=null\n");
+ break;
+ case IS_LONG:
+ php_stream_printf(out TSRMLS_CC, "param_value=%ld\n", Z_LVAL_P(param->parameter));
+ break;
+ case IS_STRING:
+ php_stream_printf(out TSRMLS_CC, "param_value=%s\n", Z_STRVAL_P(param->parameter));
+ break;
+ default:
+ php_stream_printf(out TSRMLS_CC, "param_value=unknown\n");
+ break;
+ }
zend_hash_move_forward_ex(stmt->bound_params, &pos);
}
diff --git a/ext/pdo/tests/bug_52384.phpt b/ext/pdo/tests/bug_52384.phpt
new file mode 100644
index 0000000000..45449fd93a
--- /dev/null
+++ b/ext/pdo/tests/bug_52384.phpt
@@ -0,0 +1,81 @@
+--TEST--
+PDO Common: Bug #52384 (debugDumpParams does not emit the bind parameter value)
+--SKIPIF--
+<?php # vim:ft=php
+# PDOTEST_DSN=sqlite::memory: REDIR_TEST_DIR=ext/pdo/tests/ TEST_PHP_EXECUTABLE=sapi/cli/php sapi/cli/php run-tests.php ext/pdo/tests/pdo_038.phpt
+if (!extension_loaded('pdo')) die('skip');
+$dir = getenv('REDIR_TEST_DIR');
+if (false == $dir) die('skip no driver');
+require_once $dir . 'pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
+require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
+$db = PDOTest::factory();
+
+$calories = 150;
+$colour = 'red';
+$tf = true;
+$n = null;
+$lob = str_repeat('a',1000);
+$dob = '1978-10-17';
+
+$sth = $db->prepare('SELECT 1 WHERE 1');
+$sth->bindParam(':calories', $calories, PDO::PARAM_INT);
+$sth->bindValue(':colour', $colour, PDO::PARAM_STR);
+$sth->bindValue(':tf', $tf, PDO::PARAM_BOOL);
+$sth->bindValue(':n', $n, PDO::PARAM_NULL);
+$sth->bindValue(':lob', $lob, PDO::PARAM_LOB);
+$sth->bindValue(':dob', $dob, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT);
+
+$sth->debugDumpParams();
+unset($dbh);
+?>
+--EXPECT--
+SQL: [16] SELECT 1 WHERE 1
+Params: 6
+Key: Name: [9] :calories
+paramno=-1
+name=[9] ":calories"
+is_param=1
+param_type=1
+is_input_output=0
+param_value=150
+Key: Name: [7] :colour
+paramno=-1
+name=[7] ":colour"
+is_param=1
+param_type=2
+is_input_output=0
+param_value=red
+Key: Name: [3] :tf
+paramno=-1
+name=[3] ":tf"
+is_param=1
+param_type=5
+is_input_output=0
+param_value=true
+Key: Name: [2] :n
+paramno=-1
+name=[2] ":n"
+is_param=1
+param_type=0
+is_input_output=0
+param_value=null
+Key: Name: [4] :lob
+paramno=-1
+name=[4] ":lob"
+is_param=1
+param_type=3
+is_input_output=0
+param_value=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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