Re: Fix the inconsistent behavior of PDO::PARAM_XXX

From: Date: Mon, 06 Nov 2023 13:57:39 +0000
Subject: Re: Fix the inconsistent behavior of PDO::PARAM_XXX
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-121599@lists.php.net to get a copy of this message
Hi, I think this is probably the same problem that Matteo ran into, but when using emulate mode, pgsql errors out with code like this: ``` <?php $db = new PDO( pgsql:/* dsn */, /* username */, /* password */, [ PDO::ATTR_EMULATE_PREPARES => true, ], ); $db->exec('CREATE TABLE test2 (val BOOLEAN)'); $stmt = $db->prepare('INSERT INTO test2 VALUES(:val)'); $stmt->bindValue(':val', 1, PDO::PARAM_INT); $stmt->execute(); ``` ``` Fatal error: Uncaught PDOException: SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "val" is of type boolean but expression is of type integer ``` It seems a little strange that whether an error occurs or not depends on whether you are in emulation mode or not. Saki

« previous php.internals (#121599) next »