Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.