Skip to content

Unable to check PDO::ATTR_STRINGIFY_FETCHES configuration #12969

Closed

Description

@janedbal

Description

The following code:

<?php
$pdo = new PDO('mysql:host=mysql;port=3306', 'root', 'secret');
var_dump(
    $pdo->getAttribute(PDO::ATTR_STRINGIFY_FETCHES)
);

Resulted in this output:

Fatal error: Uncaught PDOException: SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in /app/pdo.php on line 3

But I expected this output instead:

int(0);

It seems like I cannot verify how PDO is configured regarding this option. When $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true) is used, true is returned and the behaviour changes. This behaviour applies for at least mysql, pgsql and sqlite.

Full dockerized replication repository: https://github.com/janedbal/php-pdo-get-attribute-bug

PHP Version

PHP 8.3.0

Operating System

No response

Activity

  1. SakiTakamachi commented on Dec 18, 2023

    @SakiTakamachi
    Member

    This is a known issue. In #12793 I made a fix for this issue on master. I targeted the master branch for changes because there were some other existing behavior changes.

    @Girgias
    At least regarding the part of getting PDO::ATTR_STRINGIFY_FETCHES with getAttribute(), I don't think it will cause a BC break even if we backport it. What do you think?

  2. janedbal commented on Dec 18, 2023

    @janedbal
    Author

    Thx, I'd love to see this backported!

    Currently I'm working on phpstan-doctrine feature that attempts to autodetect stringification behaviour and this is blocking issue for me.

  3. SakiTakamachi commented on Dec 18, 2023

    @SakiTakamachi
    Member

    I have created the backport PR to 8.2 for the time being.

    #12970

  4. added 2 commits that reference this issue on Dec 22, 2023
    b333164
    c3f6579
  5. added a commit that references this issue on Dec 22, 2023
    702fbc8
  6. janedbal commented on Dec 22, 2023

    @janedbal
    Author

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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