简体   繁体   English

Codeigniter:致命错误:在非对象上调用成员函数num_rows()

[英]Codeigniter : Fatal error: Call to a member function num_rows() on a non-object

I have problem in link of my script by Codeigniter. 我在Codeigniter的脚本链接中遇到问题。 I have this URL :- 我有这个网址:-

localhost/index.php/admin/orders/ Its get me all order of product, But when i add any character in the end of link like this : localhost / index.php / admin / orders /它可以获取所有产品订单,但是当我在链接末尾添加任何字符时,如下所示:

localhost/index.php/admin/orders/ggg The user see some error message. localhost / index.php / admin / orders / ggg用户看到一些错误消息。

Fatal error: Call to a member function num_rows() on a non-object in 

How can save my link, And hidden this message. 如何保存我的链接,并隐藏此消息。

My Controller :- 我的控制器:

function orders()
{
    $data['orders'] = $this->admin_model->getOrderList();
    $data['total']  = $this->admin_model->getOrderCount();
    $this->load->view('admin/orders',$data);
}

My Model:- 我的模特:

 function getOrderList()
{
    $page = $this->uri->segment(3);
    if($page=='')
        $page=1;

    $start = ($page-1)*RECORDS_PER_PAGE;
    $end = RECORDS_PER_PAGE;

    $this->db->select("*");
    $this->db->limit($end,$start);

    $this->db->order_by('order_id','DESC');
    $result = $this->db->get('wg_orders');
    if($result->num_rows()>0)
    return $result->result();
    else
    return 'empty';
}

You can use count() function as well. 您也可以使用count()函数。

In Controller 在控制器中

    function orders()
    {
        $data['orders'] = $this->admin_model->getOrderList();
        $data['total']  = $this->admin_model->getOrderCount();
        $this->load->view('admin/orders',$data);
    }

In Model 在模型中

    function getOrderList()
    {
        $page = $this->uri->segment(3);
        if($page=='')
            $page=1;

        $start = ($page-1)*RECORDS_PER_PAGE;
        $end = RECORDS_PER_PAGE;

        $query = $this->db->query("SELECT * FROM table_name WHERE (your_argument) LIMIT $end, $start ORDER BY order_id DESC ");
        $result = $query->result_array();
        $count = count($result);

        if($count>0)
        {
            return $result;
        }
        else
        {
            return 'empty';
        }
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Codeigniter / Postgresql:致命错误:在非对象上调用成员函数num_rows() - Codeigniter/Postgresql: Fatal error: Call to a member function num_rows() on a non-object 在codeigniter中的非对象上调用成员函数num_rows() - Call to a member function num_rows() on a non-object in codeigniter Codeigniter调用非对象上的成员函数num_rows() - Codeigniter Call to a member function num_rows() on a non-object 致命错误:在非对象上调用成员函数num_rows() - Fatal Error:Call to a member function num_rows() on a non-object PHP致命错误:在非对象上调用成员函数num_rows() - PHP Fatal error: Call to a member function num_rows() on a non-object 在非对象上调用成员函数 num_rows() - Call to a member function num_rows() on a non-object 使用codeigniter调用非对象上的成员函数num_rows() - Call to member function num_rows() on non object using codeigniter 致命错误:在第137行的/home/*/public_html/application/core/MY_Controller.php中的非对象上调用成员函数num_rows() - Fatal error: Call to a member function num_rows() on a non-object in /home/*/public_html/application/core/MY_Controller.php on line 137 在模型文件中的非对象上调用成员函数num_rows() - Call to a member function num_rows() on a non-object in model file Codeigniter 致命错误:调用非对象上的成员函数 query() - Codeigniter Fatal error: Call to a member function query() on a non-object
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM