Consider the following code below, I've been thought by Lynda.com to create a database class like this, my question is why not create a static method for the database entirely instead of storing an instance into a static property?
<?php
class Database {
private $conn;
private static $init;
public function __construct() {
$this->conn = new mysqli('localhost','root','root','mydb');
}
public static function getInstance() {
self::$init = new self();
return self::$init;
}
}
$db = Database::getInstance();
?>