Flow/Several databases

From Aimeos documentation

Flow
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 usually defined in the Configuration/Settings.yaml' file of your TYPO3 Flow application:

  1. TYPO3:
  2.   Flow:
  3.     persistence:
  4.       backendOptions:
  5.         host: '<host name or IP address>'
  6.         dbname: '<database>'
  7.         user: '<username>'
  8.         password: '<secret password>'

These settings are also used by the Aimeos Flow package by default. A standard database resource definition looks like:

  1. Aimeos:
  2.   Shop:
  3.     resource:
  4.       db:
  5.         adapter: mysql
  6.         host: '<host name or IP address>'
  7.         port: '<port number>'
  8.         database: '<database>'
  9.         username: '<username>'
  10.         password: '<secret password>'
  11.         stmt: ["SET NAMES 'utf8'", "SET SESSION sql_mode='ANSI'"]
  12.         limit: 2
  13.         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 Configuration/Settings.yaml file:

  1. Aimeos:
  2.   Shop:
  3.     resource:
  4.       'db-order':
  5.         adapter: mysql
  6.         host: '<host name or IP address>'
  7.         port: '<port number>'
  8.         database: '<database>'
  9.         username: '<username>'
  10.         password: '<secret password>'
  11.         stmt: ["SET NAMES 'utf8'", "SET SESSION sql_mode='ANSI'"]
  12.         limit: 2
  13.         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