[Typo3-dev] Connecting to a different db kills typo3 db connection?

Dom Stockdale dom at adymo.com
Mon Aug 1 22:27:21 CEST 2005


Hi I can't tell if you found a solution from this thread but if you put
the following it will sort it out.

It's a real hack but I'm not proud ( after your mysql_close).

$GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username,
TYPO3_db_password);
	
$GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db);

Dmitry Dulepov wrote:
> Hi!
> 
> I am trying to connect to a different mysql database from my extension.
> Code is similar to:
> 
> ---------------------
> $rc = mysql_connect('localhost', 'aaa', 'bbb', true);
> mysql_select_db('ccc', $rc);
> $res = mysql_query('SELECT * FROM something WHERE name=\'' .
> 	mysql_real_escape_string($userId, $rc) . '\'', $rc);
> if (false !== $res) {
> 	$this->rec = mysql_fetch_assoc($res);
> 	mysql_free_result($res);
> }
> mysql_close($rc);
> ---------------------
> 
> As you see I am creating a new link (last parameter to mysql_connect),
> so it should not interfer with any other database connection. However,
> any extension, that uses TYPO3_DB after my extension, looses database
> connection when the code above is executed. If I replace the last line
> (mysql_close) with mysql_select_db('typo3db_name', $rc) than everything
> works fine!
> 
> The code above is located in a separated function, no global variables
> are used.
> 
> Is this a bug? I am using version 3.7.0 with PHP 4.3.11 and MySQL 3.23.
> Typo3 uses mysql_pconnect.
> 
> Dmitry.




More information about the TYPO3-dev mailing list