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
Post a Comment