Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Undefined method Phalcon\Mvc\Model\Manager::getConnection()

While trying to get DB connection in controller through modelManager, I got this errors:

Fatal error: Call to undefined method Phalcon\Mvc\Model\Manager::getConnection() Fatal error: Call to undefined method Phalcon\Mvc\Model\Manager::getConnectionService():

Example: var_dump($this->modelsManager->getConnectionService());

But in documentation said that there are such functions



83.0k
Accepted
answer

The models manager does return a connection that is related to a model:

$connection = $this->modelsManager->getConnection(new Robots());

These methods were removed in 1.0.0, please use the 1.0.0 API:

http://docs.phalconphp.com/en/1.0.0/api/Phalcon%5Mvc%5Model%5Manager.html

Oh, missed this version. Thank you