05-18-2010, 11:05 AM
|
#2 (permalink)
|
|
The Visitor
Join Date: May 2010
Location: sarf Landin
Posts: 3
Thanks: 0
|
OK - the code I posted works. The problem was in the function connect() which was overwriting the dbh instance with the return from the mysql connect. So, for the sake of completeness, here's the fixed version of the bit that was producing the error:
Code:
private static $dbc; // mysql connection
private static function connect()
{
self::$dbc = @mysql_connect(self::$dbhost,self::$dbuser,self::$dbpassword);
if ( ! self::$dbc )
{
// error handling
}
if ( !@mysql_select_db(self::$dbname,self::$dbc))
{
// more error handling
}
}
Good thread on this already: How to use the Singleton design pattern
Last edited by JohnAtYM : 05-18-2010 at 11:34 AM.
Reason: supplemental link
|
|
|
|