Jump to content

My_mysqli class


Acs

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/5494-my_mysqli-class/
Share on other sites

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]
Link to comment
https://forums.phpfreaks.com/topic/5494-my_mysqli-class/#findComment-19632
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.