5

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

tereško
  • 58,060
  • 25
  • 98
  • 150

1 Answers1

1

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

seboettg
  • 195
  • 8