Question: All the singleton patterns I have seen use a reference to the object to determine if the object has been instantiated. However, if I am using a singleton to guarantee only one db connection, why not use the db connection resource link to do this? Here is the code I am using. (PS: it works fine). I use the comment to be able to search for my classes easily. 

```
/*one*/

class one
  {
  public static $db;
  private function __construct()
    {
    self::$db=new mysqli(DB_HOST, DB_USER, DB_PASS, DB_DATABASE);
    }
  public static function get()
    {
    if(self::$db==NULL)
      {
      new self();
      }
    return self::$db;
    }
  }

```

Answer: 
Define *it works fine* :)

Try to:

* compare object hashes returned from both of the methods (does matter when you use object cloning)
* connect to DB using different credentials (e.g. in unit tests)
* disconnect from the DB and reconnect again
* reset the instance of the object (now creating 1000 objects using `new` fills the memory up)
* tell some other developer to create in instance of this class, he will for sure look for `one::getInstance()` method. How do he guesses the behavior of this class?

Singletons are about global state. Looks like here you have global state + some mess.
As Macmade already pointed out, the `constructor` method doesn't return anything but an instance of the class. Assuming you always want the same instance of `mysqli`, here's how I'd do it.

```
class DBInstance
{
    protected static $db;

    private function __construct()
    {
        // intentionally empty
    }

    public static function get()
    {
        if(self::$db === NULL)
        {
            self::$db=new mysqli(DB_HOST, DB_USER, DB_PASS, DB_DATABASE);
        }

        return self::$db;
    }
}

```

It most certainly is a singleton pattern with an added bonus of separating instantiation from the instantiated class.