|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 19:00:01 2025 UTC |
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; ?>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