Page 1 of 1

Database connection in class.global.inc.php

Posted: Fri Jun 02, 2006 1:08 pm
by gnud
I originally came here to report a bug in the latest release, but after checking SVN I found it was fixed. Good work!

However, I can't say the fix looks too good.
In cmsObject::getDb(), there is (naturally) a check to see if the connection to the database failed.
It reads

Code: Select all

if (!$dbinstance || (TRUE == empty($dbinstance->_connectionID) && TRUE == empty($dbinstance->connectionId)))
			{
				var_dump($dbinstance);
				die("Database Connection failed");
			}
The condition accesses a private variable. I suggest you instead keep the return value from $dbinstance->Connect(), and check that. Alternatively, use the $dbinstance->IsConnected() method.

Re: Database connection in class.global.inc.php

Posted: Sat Jun 03, 2006 2:18 am
by Ted
Point taken.  I've changed it to use the IsConnected() method instead.  Thanks!