Developers/Several databases

From Aimeos documentation

Developers
Other languages:
English 100%


The Aimeos web shop is able to use different databases for its data domains. Thus, you can configure a separate database e.g. for all customer or order related data. These database can even use different database servers like MySQL, PostgreSQL, Oracle, SQL Server, etc. If no specific database is configured for a data domain, the default database will be used.

In fact, there are 16 different data domains which can be stored in one database each. These include domains for:

  • attribute
  • cache
  • catalog
  • coupon
  • customer
  • job
  • locale
  • log
  • media
  • order
  • plugin
  • price
  • product
  • service
  • supplier
  • text

Usually it doesn't make sense to put every data domain into an own database. Reasonable data domains are those which will grow very big in your setup. Candidates are the log and order domains which might fill up with data over the time.

You need to create a resource.php file in the config directory that will contain the database configuration:

  1. <?php
  2. return array(
  3.     'db-<domain>' => array(
  4.         'adapter' => 'mysql',
  5.         'host' => '<host name or IP address>',
  6.         'port' => '<if a non-standard port is used>',
  7.         'database' => '<database name>',
  8.         'username' => '<name of the database user>',
  9.         'password' => '<secret password for the user>',
  10.         'stmt' => array( "SET NAMES 'utf8'", "SET SESSION sql_mode='ANSI'" ),
  11.         'limit' => 2,
  12.         'opt-persistent' => 0
  13.     ),
  14. );

You can add an entry for every data domain replacing the <domain> placeholder in the example above with the name of the data domain. For the customer data domain it would be e.g.

  1.     'db-customer' => array(
  2.         'adapter' => 'mysql',
  3.         'host' => 'localhost',
  4.         'port' => '3306',
  5.         'database' => 'my_typo3_website',
  6.         'username' => 'myuser',
  7.         'password' => 'secret',
  8.         'stmt' => array( "SET NAMES 'utf8'", "SET SESSION sql_mode='ANSI'" ),
  9.         'limit' => 2,
  10.         'opt-persistent' => 0
  11.     ),

The fallback database (which is also the standard database) is already configured within the Aimeos TYPO3 extension and is the one of your TYPO3 installation. If you want to move the shop related tables to their own database, add a configuration entry for db to your configuration file:

  1.     'db' => array(
  2.         ...
  3.     ),

During a request, only one database connection per configured database should be open. Limiting the maximum connections to "1" works until you try to execute run the setup tasks as some of them need two connections to for reading and writing in parallel.