Skip to content

Loading…

DBAL-625: Extend Connection #1841

Closed
doctrinebot opened this Issue · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user mounte:

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::FETCHKEYPAIR);
}

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

Thanks for your support,
Thierry

@doctrinebot

Comment created by @deeky666:

Are you sure the fetch mode PDO::FETCHKEYPAIR 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.

@doctrinebot

Comment created by @deeky666:

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 :)

@doctrinebot

Issue was closed with resolution "Invalid"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.