Skip to content

Null normalizes to 'f' when PDO::ATTR_EMULATE_PREPARES = true #12581

Open
@juffin-halli

Description

@juffin-halli

Description

The following code:

<?php

$pdo = new PDO(
    'pgsql:host=localhost;port=5432;dbname=test',
    'postgres',
    'postgres',
    [
        PDO::ATTR_EMULATE_PREPARES => true,
    ],
);

/** @var PDOStatement $stmt */
$stmt = $pdo->prepare('SELECT :bool_val as bv');
$stmt->bindValue(':bool_val', null, PDO::PARAM_BOOL);
$stmt->execute();

foreach ($stmt->getIterator() as $item) {
    var_dump($item['bv']);
}

Resulted in this output:

string(1) "f"

But I expected this output instead:

NULL

When ATTR_EMULATE_PREPARES not used, NULL is actually returned.

PHP Version

PHP 8.2.11

Operating System

Alpine Linux 3.18

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions