[TYPO3-dev] External DB connection inside an extension ?
Jigal van Hemert
jigal at xs4all.nl
Sun Jul 20 12:37:31 CEST 2008
Very late reply; finally catching up with loads of e-mail :-)
Dmitry Dulepov [typo3] wrote:
> Stephane wrote:
>> Then, in my extension, I open a new connection to my external db
>> via mysql_connect command. I'm able to get all necessaries datas
>> with queries ... no problem .. until here.
>>
>> The problem come just after. After this mysql_query on external db,
>> I don't know why but I lost the connection to Typo3 db :(.
>
> This happens in PHP if you use the same user name and password to
> different databases. PHP just selects another database and reuses the
> same connections. Normally each database must have its own user.
There is a fourth (and fifth) parameter for mysql_connect():
resource mysql_connect ([ string $server [, string $username [,
string $password [, bool $new_link [, int $client_flags ]]]]] )
If you set $new_link to TRUE, it will force a new connection even if the
same server + username + password are used. No need to reconnect the
TYPO3_DB again :-)
--
Jigal van Hemert.
More information about the TYPO3-dev
mailing list