Reputation: 1864
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
Upvotes: 1
Views: 880
Reputation: 28906
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.
Upvotes: 1