We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

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



98.9k
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.phalcon.io/en/1.0.0/api/Phalcon_Mvc_Model_Manager.html

Oh, missed this version. Thank you