Postado originalmente por
Renato
meteu singleton na porra toda euheuhuheuhe
Único Singleton que eu lembro de banco de dados é esse aqui:
Código PHP:
/**
* Connect to Driver
* Instantiate and connect to Driver
*
* @param string Driver name
* @param boolean Set default driver
* @return boolean
*/
public function Connect($driver, $default = FALSE)
{
require_once(self::LibGetRealPath(self::DRIVER_LIB_FOLDER."driverInstance.lib.php"));
if(!$this->drivers[$driver])
{
if(!file_exists(self::LibGetRealPath(self::DRIVER_LIB_FOLDER).strtolower($driver)."Client.lib.php"))
return FALSE;
require_once(self::LibGetRealPath(self::DRIVER_LIB_FOLDER).strtolower($driver)."Client.lib.php");
$this->drivers[$callClient->Name] = $callClient;
}
else
$callClient = $this->drivers[$driver];
if($default || !$this->localDriver)
$this->localDriver = $callClient->Name;
else
$this->tempDriver = $callClient->Name;
$callClient->settings = $this->settings[$driver];
$callClient->StartConnection();
switch($callClient->Result()->Connect)
{
case "NO_PHP_EXTENSION" :
$this->DebugSQL(self::instanceClass()->LoadMessages($callClient->Name, "logExtensionNotLoaded"));
$this->ErrorSQL(self::instanceClass()->LoadMessages($callClient->Name, "extensionNotLoaded"));
break;
case "CONNECTION_FAILED" :
$this->DebugSQL(self::instanceClass()->LoadMessages($callClient->Name, "logConnectionFailed"));
$this->ErrorSQL(self::instanceClass()->LoadMessages($callClient->Name, "connectionFailed"));
break;
case "DATABASE_FAILED" :
$this->DebugSQL(self::instanceClass()->LoadMessages($callClient->Name, "logDatabaseFailed"));
$this->ErrorSQL(self::instanceClass()->LoadMessages($callClient->Name, "databaseFailed"));
break;
case "CONNECTED" :
$this->tempDriver = NULL;
return TRUE;
break;
}
$this->tempDriver = NULL;
}
asdhasiduhasduihasduiashduihasu