mysql - PHP OOP and MySQLi connection = Fatal error: Call to undefined method mysqli::arrayQuery() -


please tell me i've done wrong? , how work base better? connection works, can not see information base. get:

fatal error: call undefined method mysqli::arrayquery()

i can't understand how fix it, google didn't either.

<?php class proc{     protected $db;     function __construct(){         $this->db=new mysqli('localhost', 'user', 'password', 'basename');         $this->db->query("set names utf8");}     function __destruct(){unset($this->db);}     function getall(){         $sql="select * users";         $result = $this->db->arrayquery($sql, sqlite_assoc);         return $result;} }  $yo = new proc();  $users = $yo->getall(); echo "all users: ".count($users); foreach ($users $user){     $id = $user["id"];     $n = $user["name"];     echo "{$id} - {$n}<br/>";} ?> 

a little fix , work perfect! all!

<?php class proc{     protected $db;     function __construct(){         $this->db=new pdo("mysql:host=localhost;dbname=basename", user, password);         $this->db->query("set names utf8");}     function __destruct(){unset($this->db);}     function getall(){         $sql="select * users";         $result = $this->db->query($sql);         return $result;} } $yo = new proc(); $users = $yo->getall(); foreach ($users $user){     $id = $user["id"];     $n = $user["name"];     echo "{$id} - {$n}<br/>";} ?> 

what database using? sqlite or mysql ?

because per php docs, guess function arrayquery can used sqlite databases


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -