Please tell me what I've done wrong? And how to work with base better? Connection works, but I can not see information from base. I just get:

请告诉我我做错了什么?如何更好地与基地合作?连接是有效的,但是我无法从基座上看到信息。我刚刚得到:

Fatal error: Call to undefined method mysqli::arrayQuery()

致命错误:调用未定义的mymethod sqli::arrayQuery()

I can't understand how to fix it, Google didn't help 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 * FROM users";
        $result = $this->DB->arrayQuery($sql, SQLITE_ASSOC);
        return $result;}
}

$Yo = new Proc();

$users = $Yo->GetAll();
echo "All users: ".count($users);
foreach ($users as $user){
    $id = $user["ID"];
    $n = $user["Name"];
    echo "{$id} - {$n}<br/>";}
?>

A little fix and all work perfect! Thanks to 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 * FROM users";
        $result = $this->DB->query($sql);
        return $result;}
}
$Yo = new Proc();
$users = $Yo->GetAll();
foreach ($users as $user){
    $id = $user["ID"];
    $n = $user["Name"];
    echo "{$id} - {$n}<br/>";}
?>

1 个解决方案

#1


1

What database are you using? SQLite or mysql ?

您正在使用什么数据库?SQLite或mysql吗?

Because as per the PHP DOCS, I guess the function arrayQuery can be used only for SQLite databases

因为根据PHP文档,我猜想函数arrayQuery只能用于SQLite数据库

更多相关文章

  1. MySQL官网示例数据库emploees分析使用
  2. mysql——数据库设计中int与varchar中的长度含义
  3. java链接数据库--Mysql
  4. 数据库_MySQL_复杂SQL的书写顺序与执行过程
  5. mysql dos命令 创建表单,选择数据库
  6. Spring Security ACL使用MySQL配置与数据库脚本
  7. 需要从mysql数据库中获得productdata。
  8. 数据库行转列和列转行小例子
  9. MySQL数据库储存bit类型的值报错

随机推荐

  1. mysql 批量更新与批量更新多条记录的不同
  2. MySQL第一课(基础、库操作、表操作)
  3. labview使用DSN与数据库的连接包括access
  4. 【文档】五、Mysql Binlog事件结构
  5. g++ 连接 mysql 编译报错 /usr/bin/ld: c
  6. Mysql 查看及设置事物隔离级别
  7. mysql学习之路_外键
  8. 如何用mysql或Navicat实现流水号的插入
  9. 远程服务器CentOS7安装MySQL并用本地Navi
  10. 在mac中配置apache+php5.3+mysql的环境,修