xxarmoxx
Mar 15th, 2009, 02:09 AM
I have the following class:
<?php
// this is a singelton database connect class
class dbconnect {
// Store the single instance of Database
private static $m_pInstance;
private function __construct() {
// *** Database Connect ***
$dblink = mysql_connect('localhost', 'root', 'pwd') OR die(mysql_error());
$m_pInstance = mysql_select_db(",ydb") or die(mysql_error());
}
private function __clone() {
}
public static function getInstance()
{
if (!self::$m_pInstance)
{
self::$m_pInstance = new dbconnect();
}
return self::$m_pInstance;
}
}
?>
but I get the following error when I have muliple include statements using this class:
Fatal error: Cannot redeclare class dbconnect in
I know I need some code in the __Clone function. Im not sure what to put in there, can someone help?
<?php
// this is a singelton database connect class
class dbconnect {
// Store the single instance of Database
private static $m_pInstance;
private function __construct() {
// *** Database Connect ***
$dblink = mysql_connect('localhost', 'root', 'pwd') OR die(mysql_error());
$m_pInstance = mysql_select_db(",ydb") or die(mysql_error());
}
private function __clone() {
}
public static function getInstance()
{
if (!self::$m_pInstance)
{
self::$m_pInstance = new dbconnect();
}
return self::$m_pInstance;
}
}
?>
but I get the following error when I have muliple include statements using this class:
Fatal error: Cannot redeclare class dbconnect in
I know I need some code in the __Clone function. Im not sure what to put in there, can someone help?