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

Ries van Twisk typo3 at rvt.dds.nl
Thu Jul 10 23:13:49 CEST 2008


you can use DBAL or rvt_adodb.

rvt_adodb uses a DBAL compatible syntax, but will not slow down your  
overall TYPO3 installation.

rvt_adodb will just open an additional  connection for you at the  
moment TYPO3 initializes a DB connection.


Ries

On Jul 10, 2008, at 11:07 AM, Stephane wrote:

> 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);
> $mydb = mysql_select_db($dbname, $mylink);
> ...
> $result = mysql_query($myquery, $mylink);
> [ ok I'm able to get external records ]
> ...
> $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->table,
> $whereClause);
> [always = 0 :( ]
> ...
> $GLOBALS['TYPO3_DB']->connectDB();
> [now it's ok again, I could access to Typo3 db (normal I create a new
> link ressource) ... :s ]
>
> I have try to use also "datasources" and "adob" approach (as done in
> rlmp_extdbauth for example) instead of "direct php approach", but with
> the same result :(. I try also pconnect or not, using
> t3lib_DB::sql_pconnect functions ... a lot of test but without better
> results ... Typo3 seems to use current active database, and not the
> $link information
>
> I'm using Typo3 4.2.1 and develop a service extension ...
>
> What is wrong in my approach ? It's a Typo3 know issue (with a  
> solution
> ;)) or a problem on my php/mysql configuration ?
>
> Thanks a lot for your help (and sorry for my english)
>
> BR
>
> Stef
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev





More information about the TYPO3-dev mailing list