[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • From: typo3 at fm-world.ru (Dmitry Dulepov)
  • Date: Mon, 01 Aug 2005 10:54:25 +0300

Hi!

Well, the problem has happened with macina_banners, which uses TYPO3_DB
variable.

Actually, many extensions (for example, mininews) use exactly this
("TYPO3_db"). This is a global variable and should be used as
$GLOBALS['TYPO3_db'], not symply as TYPO3_db. May be, this is a problem?
I believe, "TYPO3_db" as such should not be defined at all inside
functions because it is not a constant. A typical use of this variable is:
            $res = mysql(TYPO3_db,$query);
This looks very wrong for me :(

Dmitry.

Martin Kutschker wrote:
> "Dmitry Dulepov" <typo3 at fm-world.ru> schrieb im Newsbeitrag 
> news:mailman.1.1122840113.428.typo3-dev at lists.netfielders.de...
> 
>>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.
> 
> 
> I think that many old stlye extensions use a) mysql calls directly (instead 
> of the DB layer) and b) don't use the resurce link in their mysql calls.
> 
> So they work on the last openened connection, which may be yours. Whether 
> you close the connection or not is irrelevant. The calls will use the wrong 
> db, unless as you do you switch to the TYPO3 db with a mysql_select_db. 
> Which will make problems if the dbs are not on the same db server.
> 
> Solution: write to the extension authors to fix their code.
> 
> Masi 
> 
>