Welcome Guest, Not a member yet? Register   Sign In
How manage the segment error in the URI / pagination class
#3

Of course, thanks for your reply.

This is my "all" method on my Contact Controller
Code:
    /**
     * list all contacts
     */
    public function all($startLimitResult)
    {
        //Load data from DB
        $data["totalContacts"] = $this->Contact_model->count_all_contacts($profile_id);
        $data["contacts"] = $this->Contact_model->get_page_contacts($profile_id, $startLimitResult, $this->nbsResultPerPage);
           
        //Load Languages files
        $this->lang->load('gml_general', $this->session->userdata('user_lang'));

        //Pagination class
        $this->load->library('pagination');
        $config['base_url'] = base_url() . 'contact/all/';
        $config['page_query_string'] = false;
        $config['use_page_numbers'] = false;
        $config['num_links'] = 2;

        $config['total_rows'] = $data["totalContacts"];
        $config['per_page'] = $this->nbsResultPerPage;
        $this->pagination->initialize($config);

        $this->load->view('head');
        $this->load->view('header');
        $this->load->view('contact/list_contact', $data);
    }

My model
Code:
    //Function to count all contacts
    public function count_all_contacts($userID)
    {
        $this->db->where('profile_id', $userID);
        $this->db->from('contact');
        return $this->db->count_all_results();
    }


    //Function to get all contacts
    public function get_page_contacts($userID, $startLimitResult, $nbsResultPerPage)
    {
        $this->db->where('profile_id', $userID);
        $this->db->from('contact');
        $this->db->limit($nbsResultPerPage, $startLimitResult);
        $query = $this->db->get();
       
        return $query->result();
    }


On page view

Code:
<?php echo $this->pagination->create_links(); ?>

When I select the first link or when I load https://exemple.com/contact/all/ I got this error.


Quote:An uncaught Exception was encountered
Type: ArgumentCountError
Message: Too few arguments to function Contact::all(), 0 passed in /var/www/gml-app/gml_system/core/CodeIgniter.php on line 532 and exactly 1 expected
Filename: /var/www/gml-app/gml_application/controllers/Contact.php
Line Number: 45
Backtrace:
File: /var/www/gml-app/index.php
Line: 327
Function: require_once
Reply


Messages In This Thread
RE: How manage the segment error in the URI / pagination class - by nicolas33770 - 03-09-2020, 07:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB