Symfony/Several databases

From Aimeos documentation

Symfony
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. If no specific database is configured for a data domain, the default database will be used.

The default database configuration is defined in the Resources/config/config.yml file of the Aimeos shop bundle and looks like

  1. aimeos_shop:
  2.     resource:
  3.         db:
  4.             adapter: mysql
  5.             host: %database_host%
  6.             port: %database_port%
  7.             database: %database_name%
  8.             username: %database_user%
  9.             password: %database_password%
  10.             stmt: ["SET NAMES 'utf8'", "SET SESSION sql_mode='ANSI'"]
  11.             limit: 2
  12.             opt-persistent: 0

It defines the database location and credentials as well as the default statements that are executed when opening a connection ("stmt"), the maximum allowed connections to this database for the request ("limit") and if the database connection should persist between connections ("opt-persistent"). You can define one database for each domain (e.g. order, customer, etc.) in the same way. To store all orders in a separate database, add another configuration block to your app/config/config.yml file:

  1. aimeos_shop:
  2.     resource:
  3.         db-order:
  4.             adapter: mysql
  5.             host: <hostname or IP address>
  6.             port: <server port>
  7.             database: <database name>
  8.             username: <database user>
  9.             password: <user password>
  10.             stmt: ["SET NAMES 'utf8'", "SET SESSION sql_mode='ANSI'"]
  11.             limit: 2
  12.             opt-persistent: 0

The important line contains the db-order key, which tells Aimeos that this resource configuration is for a database that should contain all data from the "order" domain (which includes all mshop_order* tables).

More details about the available domains and the necessary configuration is available in the