1

the following is the class i tried to develop in oo way in php but as a begginer in php oo i am getting and error message which i do not know how to solve. please point out the fault thanks.

class MySQLi_DB  extends mysqli {
    private static $_instance = null;


    private function __construct($db="test",$host="localhost", $user="root", $pass="") 
    {

        parent::__construct($host, $user, $pass, $db);
        if (mysqli_connect_error()) {
            die('Connect Error (' . mysqli_connect_errno() . ') '
                    . mysqli_connect_error());
        }
    }

    static public function getDB()
    {
        if(self::$_instance == null)
        {
            self::$_instance = new MySQLi_DB();
        }
        return self::$_instance;

    }

    public function select($sql)
    {
        $res =  $this->query($sql);
        return $res->fetch_all();


    }
}

i instantiate the object as below

require_once 'MySQLi_DB.php';
        $db = MySQLi_DB::getDB();
       $data =  $db->select("select * from cms");

and the error is below

Fatal error: Call to undefined method mysqli_result::fetch_all() in D:\wamp\www\Driver\MySQLi_DB.php on line 39

1

1 Answer 1

1

According to this page mysqli_result::fetch_all() is only available when the MySQL native driver is installed. Please ensure that it is installed and enabled for you configuration.

Sign up to request clarification or add additional context in comments.

2 Comments

oh thanks i think that could be the reason so how can i confirm i mean through which cfg variable i check if mysqlnd is installed ?
I wasn't able to determine the name of the cfg variable, but if you search the output of phpinfo() for 'mysqlnd' you should be able to verify whether it is installed. The documentation (dev.mysql.com/downloads/connector/php-mysqlnd) will help with installation and configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.