Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-214

Unable to use PDO::FETCH_CLASS with a call to fetch()

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-BETA2, 2.0.0-BETA3, 2.0.0-BETA4, 2.0.0-RC1-RC3, 2.0-RC4, 2.0-RC5, 2.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1, 2.1.1, 2.1.2, 2.1.3, 2.1.5, 2.1.6, 2.2-BETA1, 2.2-BETA2, 2.2-RC1/RC2, 2.2.0-RC3, 2.2, 2.2.1, 2.2.2, 2.3
    • Fix Version/s: 2.2.3, 2.3
    • Component/s: Drivers
    • Labels:
      None

      Description

      EDITED: 2nd attempt to describe this - first one was confusing.

      I don't understand why the setFetchMode() method of Doctrine\DBAL\Driver\PDOStatement drops any arguments passed to it. It means that PDO::FETCH_CLASS cannot be used with calls to fetch() and no warning is given until the point when the underlying \PDOStatement complains that no class has been specified.

        Activity

        Hide
        Antoine Froger added a comment - - edited

        In Doctrine/DBAL/Statement.php the 2nd and 3rd arguments of setFetchMode are dropped too.

        Error message example when PDO::FETCH_CLASS is used as the first argument of setFetchMode:
        $stmt->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'ClassName');
        display the error: PDOException: SQLSTATE[HY000]: General error: fetch mode requires the classname argument

        Show
        Antoine Froger added a comment - - edited In Doctrine/DBAL/Statement.php the 2nd and 3rd arguments of setFetchMode are dropped too. Error message example when PDO::FETCH_CLASS is used as the first argument of setFetchMode: $stmt->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'ClassName'); display the error: PDOException: SQLSTATE [HY000] : General error: fetch mode requires the classname argument
        Hide
        Fabien Potencier added a comment -

        This regression was introduced here: https://github.com/doctrine/dbal/commit/f4acc79a3e91059a932d7a2d43309f6f8f65fa59

        It breaks some of my websites when upgrading DBAL. So, this is not an improvement but a regression bug.

        Show
        Fabien Potencier added a comment - This regression was introduced here: https://github.com/doctrine/dbal/commit/f4acc79a3e91059a932d7a2d43309f6f8f65fa59 It breaks some of my websites when upgrading DBAL. So, this is not an improvement but a regression bug.
        Hide
        Benjamin Eberlei added a comment -

        Yes, i have to change this again.

        The problem is its complex to support the 2nd/3rd arguments in the statement caching layer, i will just throw an exception for now and add an improvement ticket.

        Show
        Benjamin Eberlei added a comment - Yes, i have to change this again. The problem is its complex to support the 2nd/3rd arguments in the statement caching layer, i will just throw an exception for now and add an improvement ticket.
        Hide
        Benjamin Eberlei added a comment -

        Fixed

        Show
        Benjamin Eberlei added a comment - Fixed
        Show
        Benjamin Eberlei added a comment - https://github.com/doctrine/dbal/commit/d3930dcdb89cc818798c8f13e4126f76cf82ef8b

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Andy Leon
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: