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.

Connect to database server

Is it posiible to connect to database server, without creating a multiple databases connections in phalcon, without using an external libs?

        $connection = new \Phalcon\Db\Adapter\Pdo\Mysql(
            [
                'host'     => 'localhost',
                'username' => 'user',
                'password' => 'pass',
                //'dbname'   => 'database1',
                'port'     => 3306,

            ]
        );
class SomeModel extends Model
{
    // ....
    /**
     * Set the table source.
     *
     * @return string
     */
    public function getSource()
    {
        return 'database1.some';
    }
}
class OtherModel extends Model
{
    // ....
    /**
     * Set the table source.
     *
     * @return string
     */
    public function getSource()
    {
        return 'database2.other';
    }
}


1.7k

I think that PDO don't allow that



64.1k
Accepted
answer

you can try with multi module app. In module.php you can specify the db connection.

If it works for you

Ok, will do it with multi modules, tnx