Skip to content

pdo_mysql with persistent connection #2315

@jeff1985

Description

@jeff1985

While trying to use doctrine with persistent pdo_mysql connections, it seemed that this is not supported.
To be clear, when you pass PDO::ATTR_PERSISTENT => true as config option for connection, an exception will be raised stating that General error: PDO::ATTR_STATEMENT_CLASS cannot be used with persistent PDO instances.

After some research, i found this answer on stackoverflow suggesting to pass a pre-created PDO instance as configuration parameter like this:

$conn = array('pdo' => $dbh);`
$this->entityManager = EntityManager::create($conn, $config);

It does work and my application is able use doctrine as usual. BUT it feels strange. My understanding is that this way we fool doctrine to use pdo without the statement class (which is by the way Doctrine\DBAL\Driver\PDOStatement). Can someone please point out, if there are any risks of using doctrine like that?

I also suggest to add the corresponding info regarding persistent connection to the docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions