summaryrefslogtreecommitdiff
path: root/ext/pdo
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2006-11-07 17:57:17 +0000
committerIlia Alshanetsky <iliaa@php.net>2006-11-07 17:57:17 +0000
commit887b3484f7797667293deef083eacee76270aabe (patch)
treea519eba7f3d34b5986edcf9dc3024564f48e8b30 /ext/pdo
parentc65a1f10cb5c3ea982e6b70ed7416b383ce906ed (diff)
downloadphp-git-887b3484f7797667293deef083eacee76270aabe.tar.gz
Fixed bug #39398 (Booleans are not automatically translated to integers).
Diffstat (limited to 'ext/pdo')
-rwxr-xr-xext/pdo/pdo_stmt.c4
-rw-r--r--ext/pdo/tests/bug_39398.phpt35
2 files changed, 39 insertions, 0 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index db46b950b8..6395490168 100755
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -278,6 +278,10 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_STR && param->max_value_len <= 0 && ! ZVAL_IS_NULL(param->parameter)) {
convert_to_string(param->parameter);
+ } else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_INT && Z_TYPE_P(param->parameter) == IS_BOOL) {
+ convert_to_long(param->parameter);
+ } else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL && Z_TYPE_P(param->parameter) == IS_LONG) {
+ convert_to_boolean(param->parameter);
}
param->stmt = stmt;
diff --git a/ext/pdo/tests/bug_39398.phpt b/ext/pdo/tests/bug_39398.phpt
new file mode 100644
index 0000000000..7b81747cf3
--- /dev/null
+++ b/ext/pdo/tests/bug_39398.phpt
@@ -0,0 +1,35 @@
+--TEST--
+PDO Common: PHP Bug #39398: Booleans are not automatically translated to integers
+--SKIPIF--
+<?php # vim:ft=php
+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();
+$db->exec("CREATE TABLE test (test INT)");
+
+$boolean = 1;
+$stmt = $db->prepare('INSERT INTO test VALUES (:boolean)');
+$stmt->bindValue(':boolean', isset($boolean), PDO::PARAM_INT);
+$stmt->execute();
+
+var_dump($db->query("SELECT * FROM test")->fetchAll(PDO::FETCH_ASSOC));
+?>
+===DONE===
+--EXPECT--
+array(1) {
+ [0]=>
+ array(1) {
+ ["test"]=>
+ string(1) "1"
+ }
+}
+===DONE===