php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57157 PDOStatement::execute() fails handling boolean 'false' parameter
Submitted: 2006-07-26 07:37 UTC Modified: 2017-03-01 22:34 UTC
Votes:13
Avg. Score:4.8 ± 0.5
Reproduced:12 of 12 (100.0%)
Same Version:2 (16.7%)
Same OS:3 (25.0%)
From: neta at blackbit dot it Assigned:
Status: Open Package: PDO PgSQL
PHP Version: 5.1.4 OS: OSX/NetBSD/FreeBSD
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-07-26 07:37 UTC] neta at blackbit dot it
Description:
------------
PDOStatement::execute() fails handling boolean 'false' 
parameter

To be noticed that the PHP TRUE bool value is handled 
correctly instead.


Reproduce code:
---------------
Long story short to reproduce:
- prepare $stat using '?' placeholders;
- assign the PHP FALSE bool value to one of these, when $stat->execute( $params_array );

Verified against PHP-5.1.4 PDO (PostgreSQL 8.1.4), both from pristine builds.

Expected result:
----------------
A (php) FALSE parameter is expected to be translated into a 
valid SQL "FALSE". 

According to my DBMS this is the case for "f", 0, FALSE.
I don't know if this bug is DB-specific though.

Actual result:
--------------
Instead of "FALSE" or 0 or "f" or whatever, it sends out to 
DBMS an empty string "". 

My DBMS (postgresql) complains profusely about this.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-06 22:09 UTC] karsten at typo3 dot org
This is a test case that reprocess the error for me, using

PHP 5.5.8 (compiled using MacPorts)
PostgreSQL 9.3.2
SQLite library 3.8.2
OS X 10.9.1

<?php

/*
CREATE TABLE "booleantest" (
  "persistence_object_identifier" serial NOT NULL,
  "hidden" boolean NOT NULL
);
 */

$handle = new PDO('pgsql:host=127.0.0.1 dbname=testdb', 'foo', 'bar');
$handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$statement = $handle->prepare('INSERT INTO booleantest (hidden) VALUES (?)');

// works as expected
$statement->execute(array(TRUE));
echo 'TRUE has been inserted' . PHP_EOL;

// dies with
// PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for type boolean: ""
$statement->execute(array(FALSE));
echo 'FALSE has been inserted' . PHP_EOL;

?>
 [2014-03-31 21:48 UTC] davividal at gmail dot com
I can reproduce this problem. Versions I'm running:

PHP 5.5.3-1ubuntu2.2 (cli) (built: Feb 28 2014 20:06:05) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies


Distributor ID:	Ubuntu
Description:	Ubuntu 13.10
Release:	13.10
Codename:	saucy

PostgreSQL 9.3.3 on x86_64-unknown-linux-gnu, compiled by gcc-4.4.real (Debian 
4.4.5-8) 4.4.5, 64-bit
 [2017-03-01 22:34 UTC] adambaratz@php.net
-Package: PDO +Package: PDO PgSQL
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Feb 18 14:01:25 2019 UTC