php - codeigniter fatal error ,试图读取数据库

标签 php mysql html codeigniter

fatal error :在第 8 行调用 C:\wamp\www\system\application\models\users_model.php 中非对象的成员函数 result()

   <?php

    class Users_model extends Model {

      function get_records()
      {
        $query = $this->db->get('users');
        return $query->result();
      }

    }
    ?>

最佳答案

出现上述错误是因为$query 的值为NULL 或非对象。这可能是因为 get('users') 未能返回正确的查询。

确保您的数据库有表 users 并且您的数据库库已正确初始化和配置。

关于php - codeigniter fatal error ,试图读取数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3064816/

相关文章:

php - PHP 中带有 PDO 语句的 print_r 应该返回什么?

mysql - 使用 Pomelo Entity Framework Core 查询 MySQL 数据库时出现问题

mysql - 无法嵌套具有属性 "query"的 cfoutput 标签,但不知道还能怎么做

html - 用数字格式化列表以及定义和解释

html - 在 css 中设置列​​表样式以内联显示

php - 在本地使用 wamp 时如何摆脱 payum "SSL certificate problem: unable to get local issuer certificate"错误

javascript - 如何限制mysql数据库输入的行数

html - 尝试在我的无序列表中移动列表元素

php - Laravel 的 Eloquent 使用什么范式?

mysql - 如何执行此查询 : multiple distinct counts