Welcome Guest, Not a member yet? Register   Sign In
Inserting into table twice..:(
#20

[eluser]toopay[/eluser]
According to your approach, i suggest more proper (and readable) structure, like this :
Code:
class Members extends Controller {
    protected $_data
    function __construct()
    {
        parent::__construct();    
        $this->load->model('Members_model');
        $this->load->model('Profile_model');
        $this->load->helper(array('form'));
        $this->load->library(array('form_validation','pagination'));
        $this->site_settings->get_site_settings();
        $this->get_common();
        $this->_data = array();
    }
    
    function index($pgoffset='')
    {
        $config = $this->set_config($this->config->item('records_per_page'),$this->config->item('records_per_page'),base_url().'index.php/members/index/',3);
        $this->pagination->initialize($config);

        $this->_data['username'] = $this->Profile_model->get_selected($this->session->userdata('user_id'))->username;
        $data = array(
                'count_no' => ($this->uri->segment(3)=='')? 0 : $this->uri->segment(3),
                'members'  => $this->Members_model->get_all($config['per_page'], $pgoffset),
                'friends'  => $this->Members_model->get_friends(),
                'pgoffset' => $pgoffset,    
        );

        $this->load->view('members/list', $data);
    }

    function search($pgoffset='')
    {
        $tags = $this->input->post('tags');
        $config = $this->set_config($this->config->item('records_per_page'),$this->Members_model->get_friends_total($tags),base_url().'index.php/members/search/'.$tags.'/',4);
        $this->pagination->initialize($config);

        $this->_data = array(
                'count_no' =>  ($this->uri->segment(4)=='')? 0 : $this->uri->segment(4),
                'frnds'    => $this->Members_model->get_friends_all($tags,$config['per_page']),
                'pgoffset' => $pgoffset,
        );
        $this->load->view('members/listfriends', $this->data);
    }
        
    function memberadd($id, $pgoffset='')
    {
        $this->Members_model->add_member($id,$member=$this->session->userdata('user_id'));
        /*$row    =      $this->Profile_model->get_selected($this->session->userdata('user_id'));
        $this->data['username'] = $row->username;
        
        $config['per_page'] = $this->config->item('records_per_page');
        $config['total_rows'] = $this->Members_model->get_total_friends();
        $config['base_url'] = base_url().'index.php/members/index/';
        $config['uri_segment'] = 3;
        $row    =      $this->Profile_model->get_selected($this->session->userdata('user_id'));
        $this->data['username'] = $row->username;
        $data['count_no'] = ($this->uri->segment(3)=='')? 0 : $this->uri->segment(3);
        $data['members']=  $this->Members_model->get_all_friends($config['per_page'], $pgoffset);*/
        /*$data['pgoffset'] = $pgoffset;*/
        $this->load->view('members/listfriends', $this->data);
    }
        
    function get_common(){
        $this->site_settings->get_site_settings();
    }

    function set_config($per_page, $total_rows, $base_url, $uri_segment)
    {
        $config = array(
                'per_page'      => $per_page,
                'total_rows'    => $total_rows,
                'base_url'      => $base_url,
                'uri_segment'   => $uri_segment,
        );
        return $config;
    }
}


Messages In This Thread
Inserting into table twice..:( - by El Forum - 03-27-2011, 11:02 PM
Inserting into table twice..:( - by El Forum - 03-27-2011, 11:58 PM
Inserting into table twice..:( - by El Forum - 03-28-2011, 12:01 AM
Inserting into table twice..:( - by El Forum - 03-28-2011, 01:06 AM
Inserting into table twice..:( - by El Forum - 03-28-2011, 01:15 AM
Inserting into table twice..:( - by El Forum - 03-28-2011, 03:51 PM
Inserting into table twice..:( - by El Forum - 03-29-2011, 05:57 AM
Inserting into table twice..:( - by El Forum - 03-30-2011, 12:30 AM
Inserting into table twice..:( - by El Forum - 03-30-2011, 02:00 AM
Inserting into table twice..:( - by El Forum - 03-30-2011, 02:39 AM
Inserting into table twice..:( - by El Forum - 03-30-2011, 07:36 AM
Inserting into table twice..:( - by El Forum - 03-30-2011, 07:38 AM
Inserting into table twice..:( - by El Forum - 03-30-2011, 07:45 AM
Inserting into table twice..:( - by El Forum - 03-30-2011, 02:58 PM
Inserting into table twice..:( - by El Forum - 03-30-2011, 05:43 PM
Inserting into table twice..:( - by El Forum - 03-30-2011, 09:49 PM
Inserting into table twice..:( - by El Forum - 03-30-2011, 11:10 PM
Inserting into table twice..:( - by El Forum - 03-31-2011, 01:07 AM
Inserting into table twice..:( - by El Forum - 03-31-2011, 04:12 AM
Inserting into table twice..:( - by El Forum - 03-31-2011, 05:57 AM
Inserting into table twice..:( - by El Forum - 03-31-2011, 06:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB