[TYPO3-mvc] Retrieving and saving from and to a different database

Jigal van Hemert jigal.van.hemert at typo3.org
Sun Apr 22 11:02:53 CEST 2012


Hi Henjo,

On 22-4-2012 0:35, Henjo Hoeksma wrote:
>> I am currently looking for the possibilities to retrieve from and save to
>> a different database than the sites database.
>>
>> I have seen the Typo3DbBackend class where the database handle is set and
>> I wonder if I would extend that class using a constructor to set a
>> different database handle if that would work.

Usually the way to have part of the database tables in a different 
database is using DBAL. You can define on a per table basis which 
database connection should be used. You can even map table and field 
names; this way you can use table and field names which do not follow 
the TYPO3 standards.

There are a few restrictions and potential problems:
- you cannot use tables from different databases (connections) in a 
single query (e.g. join two tables from different database connections)
- the queries have to follow the DBAL guidelines. DBAL has to analyze 
and rewrite the queries and only supports a subset of the MySQL syntax 
(also because other DBMSs have a different feature set).

I've understood that Extbase is not fully DBAL compatible. If that is 
the case this should be a priority to fix. The core (including system 
extensions) must be DBAL compatible IMO.

Having certain properties of an object in one database and others in 
another database would be very hard if not impossible to achieve. Even a 
simple select query with a where clause which uses the value of such a 
property needs to be split in two queries to works across databases.

-- 
Jigal van Hemert
TYPO3 Core Team member

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-project-typo3v4mvc mailing list