Código PHP:
Ver original
Fatal error: Cannot make non static method mysqli::connect() static in class DataBase
He probado varias cosas y no consigo solucionarlo. La forma de llamar a la clase es:
Código PHP:
Ver original
$db = DataBase::connect();
El código es el siguiente (acortado):
Código PHP:
Ver original
class DataBase extends MySQLi{ private $lastError; private $resultSize; private $link; private $sql; private $result; private static $connection; private static $sqlQueries; private static $totalQueries; const dbDatabase = 'database'; const dbUsername = 'root'; const dbPassword = ''; const dbServer = 'localhost'; public static function connect(){ self::$connection = new DataBase(); } return self::$connection; } private function __construct(){ $this->link = parent::__construct(self::dbServer, self::dbUsername, self::dbPassword, self::dbDatabase); if($this->connect_errno == 0){ self::$totalQueries = 0; } else { echo 'Error en la conexion: '.$this->connect_error; } } function __destruct(){ $this->close(); } //*************** más metodos... }
Alguna idea?
Gracias.