Skip to content
Advertisement

ORM model for foreign database in typo3

I am writing a typo3 plugin that needs to access a database table of a pre-defined structure on a configurable MySQL / MariaDB database server. This is the model I wrote:

JavaScript

Of course this does not work as it stands, since Typo3 assumes the model to represent a table as defined by ext_tables.{php,sql} within the local typo3 database. But I want typo3 to use this model from another, configurable database server, identified by

  • host name
  • port
  • user name
  • password

How would I go about that? I want to use as much high-level abstraction as possible and do not want to write bare SQL queries using mysqli or the like.

Advertisement

Answer

You can have multiple databases attached to TYPO3 and establish a mapping for which tables this special new database should be used, refer to https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Configuration/Typo3ConfVars/DB.html#tablemapping for your specific version but the example mentioned there

JavaScript

should give you a good glimpse. Depending on your use case it could be helpful to

  1. have read-only SQL access to that database so that a destructive database compare does not invalidate the foreign system.
  2. or have some additional TYPO3-friendly fields (e.g. uid, pid) in it which help achieving what you want.
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement