Hi,
if "translations" is your second database, and "products", the first one:
in config.php:
return new \Phalcon\Config(array(
'one' => array(
//'adapter' => 'PostgreSQL',
'host' => 'localhost',
'username' => 'root',
'password' => 'myPGpass',
'dbname' => 'products',
),
'two' => array(
//'adapter' => 'Mysql',
'host' => 'localhost',
'username' => 'root',
'password' => 'myMYpass',
'dbname' => 'translations',
),
));
in services.php:
use Phalcon\DI\FactoryDefault,
Phalcon\Db\Adapter\Pdo\PostgreSQL as PgSqlAdapter,
Phalcon\Db\Adapter\Pdo\Mysql as MySqlAdapter;
$di = new FactoryDefault();
$di->set('db', function() use ($config) {
return new PgSqlAdapter(array(
'host' => $config->one->host,
'username' => $config->one->username,
'password' => $config->one->password,
'dbname' => $config->one->dbname
));
});
$di->set('translations', function() use ($config) {
return new MySqlAdapter(array(
'host' => $config->two->host,
'username' => $config->two->username,
'password' => $config->two->password,
'dbname' => $config->two->dbname
));
});
in your labels Model:
public function initialize()
{
$this->setConnectionService('translations');
}
public function getSource()
{
return 'labels';
}