Welcome Guest, Not a member yet? Register   Sign In
problems with $this->db->limit($limit, $offset); not working
#1

[eluser]dinisptc[/eluser]
this is my model


Code:
function listar_myagreement($limit,$offset,$project_uid){

        print_r('find architect limit'.$limit);
        print_r('find architect offset'.$offset);
        print_r('find architect project_uid'.$project_uid);

$this->db->where('projectUID',$project_uid);
    
        $this->db->order_by('id', 'desc');

        $this->db->limit($limit, $offset);

        $query = $this->db->get('agreement');
        
        if ($query->num_rows() > 0) {
            foreach ($query->result_array() as $row) {
                $result[] = $row;
            }
        } else {
            $result = false;
        }


        return $result;
    }


the problem is that i have 6 records with projectid =3 and with limit its only showing 3 records

this is the controller:

Code:
function listar_my_agreements() {

      if (!$this->ion_auth->logged_in())
      {
   //redirect them to the login page


   redirect('user/login', 'refresh');
      }
      else
      {
       //the user is not the site administrator
       $group = 'architect';
       if ($this->ion_auth->in_group($group))
       {

        // get the user object      
        $data->the_user = $this->ion_auth->user()->row();
        // put the user object in class wide property--->---->-----
        $this->the_user = $data->the_user;            
        // load $the_user in all displayed views automatically
        $this->load->vars($data);
                  
        /* initial data */
        $Ddata['page_details'] = array('page_title' => 'Listar Artigos');
        $Dheader = array();
        $Dmeta = array('meta_title'=>'Bemvindo a dinispt','meta_descricao'=>'Listar meus Artigos');
        $DContent['page_details'] = array('page_title' => 'Index of dinispt');
        $Dsidebar = array();
        $Dfooter = array();  
        //$Dpaginacao = array();
  

        /* Pagination  data */    
        $config['base_url'] = site_url("agreement/listar_my_agreements/");        
                                                                                 /*project uid*/
        $config['total_rows'] = count($this->agreement_model->find_by_projectuid($this->uri->segment(3)));
$config['uri_segment'] = 3;
        $config['per_page'] = 4;

        print_r($config['total_rows']);

        $this->pagination->initialize($config);
       // $Ddata['agreements']=$this->agreement_model->get_all_posts($config['per_page'],$this->uri->segment(3,0),$this->uri->segment(3));
        $Ddata['agreements']=$this->agreement_model->listar_myagreement($config['per_page'],$this->uri->segment(3,0),$this->uri->segment(3));

       print_r($Ddata['agreements']);
$Ddata['pagination'] = $this->pagination->create_links();
        /* carregar o template */      
        $this->template->write_view('meta', 'html/meta',  $Dmeta, true);  
        $this->template->write_view('header', 'html/header', $Dheader, true);    
        $this->template->write_view('content', 'onplans/list_my_agreements', $Ddata, true);
        $this->template->write_view('sidebar', 'html/sidebar_user');
        $this->template->write_view('footer', 'html/footer');
  
        $this->template->render();

       }else
         {
    redirect('user/login', 'refresh');
         }
     }//else
    }




Theme © iAndrew 2016 - Forum software by © MyBB