From 7af808909652d056beef9e66e22ce58fb50cb225 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 29 Oct 2005 03:01:19 +0000 Subject: [PATCH] Closes PECL #5809; PDOStatement::execute(array(...)) would modify its args. It should behave like bindValue() not bindParam(). --- ext/pdo/pdo_stmt.c | 6 +++++- ext/pdo/tests/pecl_bug_5809.phpt | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 ext/pdo/tests/pecl_bug_5809.phpt diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index ff9b273e42..64bc86c5ac 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -368,11 +368,15 @@ static PHP_METHOD(PDOStatement, execute) } param.param_type = PDO_PARAM_STR; - param.parameter = *tmp; + MAKE_STD_ZVAL(param.parameter); + *param.parameter = **tmp; + zval_copy_ctor(param.parameter); if (!really_register_bound_param(¶m, stmt, 1 TSRMLS_CC)) { + zval_ptr_dtor(¶m.parameter); RETURN_FALSE; } + zval_ptr_dtor(¶m.parameter); zend_hash_move_forward(Z_ARRVAL_P(input_params)); } diff --git a/ext/pdo/tests/pecl_bug_5809.phpt b/ext/pdo/tests/pecl_bug_5809.phpt new file mode 100644 index 0000000000..66f8c21e99 --- /dev/null +++ b/ext/pdo/tests/pecl_bug_5809.phpt @@ -0,0 +1,34 @@ +--TEST-- +PDO Common: PECL Bug #5809 PDOStatement::execute(array()) changes param +--SKIPIF-- + +--FILE-- +exec("CREATE TABLE test (id int(10) NOT NULL, PRIMARY KEY (id))"); +$db->exec("INSERT INTO test (id) VALUES (1)"); + +$values = array(1); +var_dump($values); +$stmt = $db->prepare('SELECT * FROM test WHERE id = ?'); +$stmt->execute($values); +var_dump($values); + +--EXPECT-- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +} -- 2.40.0