[TYPO3-core] using t3lib_db for non-TYPO3 databases on the same host

Martin Kutschker Martin.Kutschker at n0spam-blackbox.net
Thu Jul 6 15:43:03 CEST 2006

Bernhard Kraft schrieb:
> Hash: SHA1
> Martin Kutschker wrote:
>>Currently it is not possible to connect to the same db host but use another db.
>>Why? typo3_db uses mysql_[p]connect() using the connection pool. So any 
>>connect to the same server will get the same handle. Any further 
>>select_db() will affect the main handle of $TYPO3_DB.
> I didn't have any problems with the following code:
> - ------------
>          $GLOBALS[$name] = t3lib_div::makeInstance('t3lib_DB');
>          $this->connectToDB($name, $props['hostname'], $props['username'], $props['password'], $props['database']);
> - -------------


> It worked out of the box to synchronize 2 databases using $GLOBALS['TYPO3_DB'] and $GLOBALS['MY_DB']
> both were connected to different databases (sql_select_db) but on the same server

Forget to add the info that all three arguments must be the same to get a 
connection from the pool. So if you have to DBs on the same machine with 
identical users info (login and pwd) it will break. And only then, so it's 
only a minor inconvenience.


More information about the TYPO3-team-core mailing list