Ho trovato questo e credo faccia proprio al caso mio:

http://www.phpdesignpatterns.com/des...ern-singleton/

l'unica cosa che volevo capire dal seguente esempio:

Codice PHP:
class Database
{
    
// A static property to hold the single instance of the class
    
private static $instance;

    
// The constructor is private so that outside code cannot instantiate
    
private function __construct() { }

    
// All code that needs to get and instance of the class should call
    // this function like so: $db = Database::getInstance();
    
public function getInstance()
    {
        
// If there is no instance, create one
        
if (!isset(self::$instance)) {
            
$c __CLASS__;
            
self::$instance = new $c;
        }
        return 
self::$instance;
    }

    
// Block the clone method
    
private function __clone() {}
}

// To use, call the static method to get the only instance
$db Database::getInstance(); 
Dove andrò a implementare il metodo per la reale connessione al database ? Cioè quello che ho postato all'inizio ? Inoltre, in realtà l'unico problema me lo dà proprio la connessione al database mentre altri metodi tipo esecuzione di una query, oppure return del numero di righe non credo diano problemi...