为了账号安全,请及时绑定邮箱和手机立即绑定

错误消息:调用未定义的方法 CI_DB_mysqli_result::results()

错误消息:调用未定义的方法 CI_DB_mysqli_result::results()

PHP
至尊宝的传说 2022-06-17 14:18:09
我是 CodeIgniter 的新手,在连接 db 后遇到以下错误。如果有人可以帮助我,那真是太好了。我检查了 StackOverflow 中以前的答案,但没有一个对我有帮助。下面是控制器代码    <?phpdefined('BASEPATH') OR exit('No direct script access allowed');class Welcome extends MY_Controller {    public function index() {        $this->load->view('home');    }    public function adminRegister() {        //loading teh queries model         $this->load->model('queries');        //Calling the getRoles function inside the roles        $roles = $this->queries->getRoles();        print_r($roles);        exit();        $this->load->view('register');    }    public function login() {        echo 'login';    }}型号代码    <?php//Details of queries whicha re used to interact with teh databaseclass Queries extends CI_Model {//Created a function with the name getRoles      public function getRoles() {        //Fetch the reocrds from the table        $roles = $this->db->get('tbl_roles');        if ($roles->num_rows() > 0) {            return $roles->results();        }    }}?>目前不使用来自控制器的数据。任何帮助将不胜感激。提前致谢。
查看完整描述

1 回答

?
波斯汪

TA贡献1811条经验 获得超4个赞

没有结果应该是结果


参考CI 文档


class Queries extends CI_Model {

    //Created a function with the name getRoles  

        public function getRoles() {

            //Fetch the reocrds from the table

            $roles = $this->db->get('tbl_roles');

            if ($roles->num_rows() > 0) {

                return $roles->result();

            }

        }


    }


查看完整回答
反对 回复 2022-06-17
  • 1 回答
  • 0 关注
  • 102 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信