public function __construct() { $servername = "localhost"; $username = "******"; $password = "******"; $dbname = "ecommerce"; if (is_null(self::$conn)) { self::$conn = mysqli_connect('localhost', 'root', 'iti', 'ecommerce'); } }
function __construct($id = -1) { if (self::$conn == Null) { self::$conn = mysqli_connect('localhost', 'root', 'iti', 'babyshop'); } if ($id != -1) { $query = "select * from subType where id={$id} limit 1"; $result = mysqli_query(self::$conn, $query); $cat = mysqli_fetch_assoc($result); $this->id = $cat['id']; $this->name = $cat['name']; } }