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

Stephane stephane.lists at gmail.com
Thu Jul 10 17:50:11 CEST 2008


Hi

Mauro Lorenzutti wrote:
> 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.
mysql_Nconnect ? or you talk about ADOdb->NConnect ?

If you talk about mysql_connect / mysql_pconnect, this approach work 
only if you use a mysql connect # as Typo3 config.
To resume, if you try 2 mysql_connect, I lost the T3 connection
If you try with 2 mysql_pconnect, I lost the connection too
With 1 mysql_connect and 1 mysql_pconnect, this approach works but I 
think it's not a good one (pconnect should be keep as T3 parameter 
depending of hosting configuration).
>
> P.S. If you are connecting an external DB in TYPO3, have you ever tried 
> the "DB Integration" (wfqbe) extension?
I have a look on your extension. But you use also ADOdb, and I do 
exactly the same thinks as inside tx_wfqbe_connect::connect function. 
But it doesn't work in my case (thanks for your extension but I just 
need to do 1 request, I don't new all the nice stuff presented in cour 
extension).

BR

Stef
>
> Regards,
>




More information about the TYPO3-dev mailing list