Jump to content

Archived

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

Acs

My_mysqli class

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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.