In this recipe, we will introduce a technique for seamlessly merging multiple databases together for use in our models. This has uses such as creating one database for user credentials and many other databases for application data. It can also be useful when working with legacy systems.
This recipe is a bit different in that it defines and uses three separate databases. We will also use the Phalcon Developer Tools to set up a project skeleton.
Follow these steps to complete this recipe:
We need to have an application skeleton for experimentation. If you already have such an application, you can skip this step. Create a project skeleton using the
simple
template:phalcon project multiple_databases simple
Create the database,
multiple_database
:DROP TABLE IF EXISTS 'clients'; CREATE TABLE 'clients' ( 'id' int(11) NOT NULL AUTO_INCREMENT, 'name' varchar(50) NOT NULL, PRIMARY KEY ('id') ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT...