Dan
Dan

Reputation: 16236

Getting the Mongo PHP Object from an Doctrine\DBAL\Connection object

I am using Mongo via Doctrine.

Now I am in the situation where I need to get the standard \Mongo PHP driver object out of the Doctrine\DBAL\Connection wrapper object.

I have googled a lot but I can't find a way. Can you please help?

I am asking this because I need to incorporate this service that uses a Mongo object in its constructor: https://github.com/richsage/Symfony2-MongoDB-session-storage/blob/master/MongoDBSessionStorage.php

Thanks.

Upvotes: 0

Views: 1805

Answers (1)

jmikola
jmikola

Reputation: 6922

The Doctrine DBAL library is a wrapper for SQL database connections, not MongoDB. I assume you're referring to the Doctrine\MongoDB\Connection object, in which case I'll direct you to a previously answered question on the subject: https://stackoverflow.com/a/12356688/162228

For Symfony2 session handling, I would also suggest using the default MongoDbSessionHandler, which is actively maintained. For instance, it supports the MongoClient class in the 1.3.x driver version (older drivers used the Mongo class).

Upvotes: 1

Related Questions