php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81586 PDO OCI binds boolean false as NULL
Submitted: 2021-11-02 17:50 UTC Modified: -
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
From: morozov at tut dot by Assigned:
Status: Open Package: PDO OCI
PHP Version: 8.0.12 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2021-11-02 17:50 UTC] morozov at tut dot by
Description:
------------
It looks like the extension doesn't implement any special handling of the PDO::PARAM_BOOL binding type which makes the logic of binding boolean values inconsistent with the rest of the PDO extensions.

Test script:
---------------
$conn = new PDO('oci:dbname=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=XE)))', 'system', 'oracle');
$stmt = $conn->prepare('SELECT ?, ? FROM DUAL');
$stmt->bindValue(1, true, PDO::PARAM_BOOL);
$stmt->bindValue(2, false, PDO::PARAM_BOOL);
$stmt->execute();


Expected result:
----------------
array(2) {
  [0] =>
  string(1) "1"
  [1] =>
  string(1) "0"
}


Actual result:
--------------
array(2) {
  [0] =>
  string(1) "1"
  [1] =>
  NULL
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2022-12-01 05:07 UTC] farid dot jamili4118 at gmail dot com
A really good post, very thankful and hopeful that you will write many more posts like this one.		


(https://www.rapidfs.online/)php.net
 [2022-12-09 05:59 UTC] fariba dot shami326 at gmail dot com
A really good post, very thankful and hopeful that you will write many more posts like this one.		


(https://www.myacpny.me/)php.net
 [2022-12-13 09:00 UTC] Lawson525aria at gmail dot com
Hi,

I'm trying to insert a PHP boolean variable into a column defined as number. It works fine for TRUE, but fails with ORA-01400 for FALSE.

Reason for using NUMBER(1) is for portability with other DB engines.

create table test (version varchar(10), obsolete number(1) not null);
(https://www.miocado.me/)github.com
 [2022-12-30 11:56 UTC] janettabloomquist at gmail dot com
PDO OCI binds boolean false as NULL handling of the PDO::PARAM_BOOL binding type which makes the logic of binding boolean. When just working with the DBAL, you can simply use PDO::PARAM_INT or "integer" as the bind type. When working with the ORM.  (https://www.caregiver-connect.org/)github.com
 [2023-06-28 12:08 UTC] arthurfordb74708 at gmail dot com
A really good post, very useful and helpful.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 11:01:30 2024 UTC