Acs Posted March 22, 2006 Share Posted March 22, 2006 I tried to make a few additions to the mysqli class, here's the code:[code]class my_mysqli extends mysqli { var $mysql_result = array(); //construtor function my_mysqli($server,$username,$password) { parent::mysqli($server,$username,$password) or die("Falhou a ligação ao servidor MYSQL - " . $this->error); } function select_db($database) { parent::select_db($database) or die("Falhou a ligação a base de dados " . $database . $this->error); } function Query($query) { $this->mysql_result = parent::query($query) or die("Falhou a query - " . $query . $this->error); } function Close() { parrent::close(); }}[/code]I don't known why but this doesn't work, I always get the firs "or die" -> "Falhou a ligação ao servidor MYSQL"Which says that the connection to mysql failed. But if I just do a:$mysqli = new mysqli($server, $username, $password, $database) It works. Anyone please tell me what I am doing wrong please Quote Link to comment https://forums.phpfreaks.com/topic/5494-my_mysqli-class/ Share on other sites More sharing options...
wickning1 Posted March 22, 2006 Share Posted March 22, 2006 Object oriented programming has changed in PHP5. The constructor is now called "__construct()". I'm not sure how PHP 4.1+ treats mysqli, but you might try:[code]class my_mysqli extends mysqli { //construtor function my_mysqli($server,$username,$password) { parent::__construct($server,$username,$password) or die("Falhou a ligação ao servidor MYSQL - " . $this->error); }}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5494-my_mysqli-class/#findComment-19632 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.