QCubed Framework - Supporting more than one Database

Applications grow and they grow in no time. Every application begins small and then starts adding in new functionalities. Let us say that you are running a small website which deals with classified ads. The service is free in the beginning. Slowly your website catches up and you want to start a paid service. Now is the problem - you have to manage financial transactions as well as the regular data your site hosts. However, now there is a risk - if for any reason, your main site database crashes or is hacked into, you are risking your financial transactions data as well! The best way is to create a new database which would run on a different server and will have more security and stability than the other one so that even if the main site goes down, the financial transactions database still keeps running and you are not in a larger loss!

There are many use cases as such where you are going to be in need of multiple databases and may be of different types and configurations. For example, you might want to create the main site database (which shows most of the data your users see on the site) in MySQL for speed purposes and use PostgreSQL for storing the financial transactions (as PostgreSQL is transaction-safe) and use caching on the main site database and disable caching on the transactions database. For this reason, a good framework must support multiple databases and so does QCubed.

QCubed allows you to have upto 9 databases in the original configuration (just to make sure that you accidentally do not copy multiple DB configurations by mistake). If you want more than 9 databases in your application, all you have to do is to change the value of 'MAX_DB_CONNECTION_INDEX' in the configuration.inc.php file (located in /includes/configuration directory) and you are ready to go! With QCubed, all your databases can have different parameters. For example, one can be of MySQL type, another of PostgreSQL type; one can have caching enabled, another one having the same disabled, one with profiling enabled, another one having it disabled and so on. This serves you long term while you are trying to grow your application (with QCubed, the growth would be rapid anyway). To configure your databases, do have a look at configuration.inc.php as well!

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>