]> granicus.if.org Git - php/commitdiff
Fixed bug #68351 (PDO::PARAM_BOOL and ATTR_EMULATE_PREPARES misbehaving)
authorMatteo Beccati <mbeccati@php.net>
Thu, 6 Nov 2014 14:46:49 +0000 (15:46 +0100)
committerMatteo Beccati <mbeccati@php.net>
Thu, 6 Nov 2014 15:34:47 +0000 (16:34 +0100)
ext/pdo_pgsql/pgsql_statement.c
ext/pdo_pgsql/tests/bug62593.phpt

index 7da130d52b00fac0cab24372b35ec6eede52d26d..2656586856bd45b797153f0d6b8f0d0c6566e76d 100644 (file)
@@ -371,6 +371,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
                        ((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) {
                        SEPARATE_ZVAL(&param->parameter);
                        param->param_type = PDO_PARAM_STR;
+                       convert_to_boolean(param->parameter);
                        ZVAL_STRINGL(param->parameter, Z_BVAL_P(param->parameter) ? "t" : "f", 1, 1);
                }
        }
index e3ebf46ed53fab8ab4f7077ef6da6a822d7ae225..4ab4566f0011d38bee95ffe4cd3e9af529d27650 100644 (file)
@@ -34,6 +34,19 @@ $query->execute();
 $errors[] = $query->errorInfo();
 var_dump($value);
 
+// Try with strings - Bug #68351
+$value = '0';
+$query->bindParam(':foo', $value, PDO::PARAM_BOOL);
+$query->execute();
+$errors[] = $query->errorInfo();
+var_dump($query->fetchColumn());
+
+$value = "abc";
+$query->bindParam(':foo', $value, PDO::PARAM_BOOL);
+$query->execute();
+$errors[] = $query->errorInfo();
+var_dump($query->fetchColumn());
+
 $expect = 'No errors found';
 
 foreach ($errors as $error)
@@ -48,4 +61,6 @@ echo $expect;
 --EXPECTF--
 bool(true)
 bool(false)
+bool(true)
+bool(false)
 No errors found