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.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, 2.5
    • Fix Version/s: 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

        Andy Leon created issue -
        Andy Leon made changes -
        Field Original Value New Value
        Description The fetch() method of Doctrine\DBAL\Statement does not accept any arguments. So trying to use fetch(PDO::FETCH_CLASS, 'ClassName') fails. But it doesn't fail until the fetch() method is called on the actual PDOStatement object - at which point it complains that a class name has not been given.

        There's probably a good reason for this, but I can't find any documentation as to why. It seems like it's intentional based on Doctrine\DBAL\Driver\PDOStatement, as the setFetchMode() function here does not pass on the arguments it receives.
        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.
        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.2.3 [ 10210 ]
        Fix Version/s 2.3 [ 10184 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 13401 ] jira-feedback2 [ 17790 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17790 ] jira-feedback3 [ 20145 ]
        Guilherme Blanco made changes -
        Fix Version/s 2.2.3 [ 10210 ]
        Guilherme Blanco made changes -
        Affects Version/s 2.5 [ 10523 ]
        Affects Version/s 2.0.9 [ 10168 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: