Bug #44597 [Com]: [PATCH] Postgres driver does not prepare booleans correctly
| From: | dczechowski at interia dot pl | Date: | Fri, 12 Dec 2014 09:10:02 +0000 |
| Subject: | Bug #44597 [Com]: [PATCH] Postgres driver does not prepare booleans correctly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189031@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=44597&edit=1
ID: 44597
Comment by: dczechowski at interia dot pl
Reported by: kenaniah at gmail dot com
Summary: [PATCH] Postgres driver does not prepare booleans
correctly
Status: No Feedback
Type: Bug
Package: PDO related
Operating System: Red Hat 4.1.1
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
I'm using php 5.6.4 on Windows and this bug is still present
test case:
<?php
//CREATE TABLE booltest(name varchar(30) not null, bool_col BOOLEAN NOT NULL)
$db = new PDO('pgsql:host=127.0.0.1 dbname=dev', 'postgres',
'12Qwerty');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare('INSERT INTO booltest (name, bool_col) VALUES (:name,
:bool_col)');
$params = array(
'normal boolean true' => true,
'normal boolean false' => false, // this one will fail
'string boolean true' => 'true',
'string boolean false' => 'false',
'int boolean true' => 1,
'int boolean false' => 0
);
foreach ($params as $key => $value){
echo "$key...";
$stmt->execute(array('name' => $key, 'bool_col' => $value));
echo "OK! <br>";
}
echo "all OK!";
Previous Comments:
------------------------------------------------------------------------
[2014-07-24 15:44:08] marcello dot nuccio at gmail dot com
As a workaround, I use the following expression to pass boolean values:
$boolvar ?: 'false'
Very hackish, but that's the best workaround I have found.
------------------------------------------------------------------------
[2013-10-15 11:54:25] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
------------------------------------------------------------------------
[2013-08-20 18:04:11] mike@php.net
Please try using this snapshot:
http://snaps.php.net/php5.4-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
Seems to work correctly in recent versions.
------------------------------------------------------------------------
[2010-10-12 12:20:14] ddebernardy at yahoo dot com
I'm in agreement with the last commenter. The PGSQL driver handles booleans that
are typecast as integers properly, but not the actual booleans. These really ought
to work out of the box.
------------------------------------------------------------------------
[2009-10-05 06:08:33] kenaniah at gmail dot com
*Sjoerd
My apologies on the incorrect spelling.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=44597
--
Edit this bug report at https://bugs.php.net/bug.php?id=44597&edit=1