I'm using Phalcon Framework with mysql and mongo database's services connection for the models of each type. We made a mongo translations system associated to the models to save related translations to mongo db, apart from mysql model information.
With a mysql model, extending \Phalcon\Mvc\Model, I can access to database's name and other information through model's associated connection service like that:
$src->getReadConnection()->getDescriptor()['dbname'];
where $src is my Phalcon\Mvc\Model
But when I try with models extending \Phalcon\Mvc\Collection, I couldn't find any way to access to the database's name. I tried to do that through phalcon\mvc\collection methods like:
Abstract class Phalcon\Mvc\Collection
public setConnectionService (unknown $connectionService)
Sets the DependencyInjection connection service name
public getConnectionService ()
Returns DependencyInjection connection service
public MongoDb getConnection ()
Retrieves a database connection
But I don't get any good way to do that. How I supposed to get that information like in \Phalcon\Mvc\Model
You will find the method getSource() in Phalcon\Mvc\Collection, which returns the name of the collection (table name).
Your Model class should inherit from \Phalcon\Mvc\MongoCollection which inherits from Phalcon\Mvc\Collection.
EDIT: Phalcon's MongoAdapter is part of the Incubator library
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With