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

Mauro Lorenzutti mauro.lorenzutti at webformat.com
Thu Jul 10 17:27:51 CEST 2008


Hi Stephane,

> Hi Typo'Gurus
>
> I nedd your help. I have a question about external db connection inside 
> typo3 extension.
>
> I'm writing an extension who needs to get data from another db (I know, 
> accessing directly to external db is not the best way, but it's the more 
> efficient approach (for speed) than I found after testing SOAP (SOAP is 
> very very very slow) and Co).
>
> 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 :(.
>
> $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.
>
> Sample code / algo :
>
> $mylink = mysql_pconnect($server, $username, $password);
>   

I already noticed this problem and I solved it with a mysql_nconnect 
insteas of mysql_pconnect. I hope this will solve your problem.

P.S. If you are connecting an external DB in TYPO3, have you ever tried 
the "DB Integration" (wfqbe) extension?

Regards,

-- 
 Mauro Lorenzutti

e-mail:  mauro.lorenzutti at webformat.com
---------------------------------------------------------
WEBFORMAT srl | Corte Europa, 12 | I-33097 SPILIMBERGO PN
     Tel +39-0427-926.389  --  Fax +39-0427-927.653
       info at webformat.com  --  http://www.webformat.com
---------------------------------------------------------





More information about the TYPO3-dev mailing list