phalcon multible mysql instances #15779
Unanswered
RaitKivinurm
asked this question in
Q&A
Replies: 2 comments
-
Hello You will need to register several separate services, here is example:
And then use inside the code:
And if you want separate connection inside each model:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
It is also possible to create a generic DB connection service: $DI->set('db_other',function($host,$db,$username,$password,$charset = 'utf8'){
return new \Phalcon\DB\Adapter\Pdo\Mysql([
'host' => $host,
'dbname' => $db,
'username' => $username,
'password' => $password,
'charset' => $charset
]);
}); Used with: $DB = $this->di('db_other',['host name','db name','username','password']); I'm not sure if this approach could be used to set the connection service for a model though. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Is it possible to use multiple MySQL instances in the Phalcon PHP framework like so if one not answering, query same from other servers?
Beta Was this translation helpful? Give feedback.
All reactions