Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      Hi there,

      Is there any possibility to extend the Doctrine\DBAL\Driver\Connection class?

      Something like this:
      public function fetchKeyValue($statement, array $params = array())

      { return $this->executeQuery($statement, $params)->fetchAll(PDO::FETCH_KEY_PAIR); }

      Or is there a solution to get the output of the function above with the existing methods?

      Thanks for your support,
      Thierry

        Activity

        Hide
        Steve Müller added a comment -

        Are you sure the fetch mode PDO::FETCH_KEY_PAIR exists? I can find it in the docs and have never seen it either to be honest. But basically of course it is possible to extend \Doctrine\DBAL\Connection. Just subclass it and override/extend the methods you need.
        I think for your purpose it would be enough to use Connection::fetchAll(). You can set your preferred fetch style via Connection::setFetchMode(). Otherwise methods like Connection::fetchAll() will use the default fetch style which is PDO::FETCH_ASSOC.

        Show
        Steve Müller added a comment - Are you sure the fetch mode PDO::FETCH_KEY_PAIR exists? I can find it in the docs and have never seen it either to be honest. But basically of course it is possible to extend \Doctrine\DBAL\Connection. Just subclass it and override/extend the methods you need. I think for your purpose it would be enough to use Connection::fetchAll(). You can set your preferred fetch style via Connection::setFetchMode(). Otherwise methods like Connection::fetchAll() will use the default fetch style which is PDO::FETCH_ASSOC.
        Hide
        Steve Müller added a comment -

        This is not an issue. I provided you the information you need to achieve what you need and close this ticket for now. If I missed something and this is really an issue, feel free to reopen

        Show
        Steve Müller added a comment - This is not an issue. I provided you the information you need to achieve what you need and close this ticket for now. If I missed something and this is really an issue, feel free to reopen

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Thierry Baumann
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: