I'm trying to set up multiple database connections, and things aren't entirely clear.
I've seen https://docs.phalcon.io/en/latest/reference/models.html#setting-multiple-databases https://stackoverflow.com/questions/22197678/how-to-connect-multiple-database-in-phalcon-framework
and I have placed this in the top of app/config.php
$di = new Phalcon\DI();
$di->set('[connection name]', function() {
return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
[connection array]
));
});
along with other sets of $di-set 's
before the return new \Phalcon\Config(array( 'database' => array(
and in a model I have:
public function initialize()
{
$this->setConnectionService('[database name]');
}
I get "Service '[connection name]' was not found in the dependency injection container" back.
What is the right way to add multiple database connections, and in what files, sequence etc? And how would I use those connections, in what files?