[TYPO3-dev] External DB connection inside an extension ?

Dmitry Dulepov [typo3] dmitry at typo3.org
Thu Jul 10 19:49:08 CEST 2008


Hi!

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.

> $GLOBALS['TYPO3_DB']->sql_num_rows return always return 0 (records exist 
> of course), until I call back $GLOBALS['TYPO3_DB']->connectDB().
> After this call I could again access to Typo3 db.

Yes, this call will select TYPO3 database again :)

-- 
Dmitry Dulepov
TYPO3 Core team
More about TYPO3: http://typo3bloke.net/
Subscribe: http://typo3bloke.net/rss.xml




More information about the TYPO3-dev mailing list