I'm starting with object oriented programming, but I know PHP procedural style pretty well I'd say. I'm working on a ticket support site for this website.This mysqliSingleton class was in a question I previously visited. I only added the set_charset() method to feet my database. By the way, should that line be in the __constructor or in the init method?class mysqliSingleton {private static $instance;private $connection;private function __construct() {    $this->connection = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);    $this->connection->set_charset('utf8');}public static function init() {    if(is_null(self::$instance)) {        self::$instance = new mysqliSingleton();    }    return self::$instance;}public function __call($name, $args) {    if(method_exists($this->connection, $name)) {         return call_user_func_array(array($this->connection, $name), $args);    } else {         trigger_error('Unknown Method ' . $name . '()', E_USER_WARNING);         return false;    }}}This is a piece of my ticket class which also has other methods delete, getFromUser, getAll, and some others:class Ticket extends mysqliSingleton {private $mysqli;public function __construct() {    $this->mysqli = mysqliSingleton::init();//Singleton db}//Submit a ticketpublic function submitTicket($idusuario, $problem,$moreinfo){    $query = INSERT INTO tbl_name (tbl_field,tbl_problem,tbl_moreinfo) VALUES (?,?,?);    $stmt = $this->mysqli->prepare($query) or die($this->mysqli->error);    if ($stmt) {        $stmt->bind_param('iss',$idusuario,$problem,htmlentities($moreinfo));        if ($stmt->execute()) {            return true;        } else return false;//Problem sql    }}}Am I using the singleton pattern right? But (unfortunately) after I code that, I starting reading more about abstract classes and Interfaces, and I've started to doubt if this is right. By the way, the ticket class is one of many classes that will extend to mysqliSingleton.
OOP MySQLi singleton
php;object oriented;mysqli;singleton
Well, although this code belongs to Codereview@stackexchenge, but as nobody cares to follow any rules here - so I would.There are too much problems with your code, ut to outline most:It seems you don't quite understand what singleton is and why use it.There is no point in extending application class from database handler class. trigger_error('Unknown Method ') is apparently redundant. PHP can handle absent methods as well.Never use die() in production code. This whole class makes very little sense as it don't help you to handle mysqli even a bit. Frankly, exactly the same result you can have without any singleton class but just by creating mysqli instance and making itpublic function __construct() {    global $mysqli;    $this->mysqli = $mysqli;}