We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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:

https://docs.phalcon.io/en/1.0.0/api/Phalcon_Mvc_Model_Manager.html

Oh, missed this version. Thank you