Welcome Guest, Not a member yet? Register   Sign In
help: how to call my function model in my controller?
#1

[eluser]kikz4life[/eluser]
i have a function model name getDetailList($ids). I have to get the value of $ids and call it in my controller. When i echo $ids it returns the right value.

this is my model
Code:
function getDetailList($ids)
    {
        $item=$this->input->post('item');

        $page = $this->input->post('page');
        $limit = $this->input->post('rows');
        $sidx = $this->input->post('sidx');
        $sord = $this->input->post('sord');

        if (!$sidx) $sidx = 'sec_companyaccess.user_id';
        if (!$sord) $sord = 'desc';    
        
        if (!$page) $page = 1;
        if (!$limit) $limit = 25;
        
        $start = (($page-1) * $limit);
        
        $this->db->start_cache();

        $this->db->join('maint_company','sec_companyaccess.company_id=maint_company.company_id','left');
        $this->db->join('sec_users ','sec_companyaccess.user_id=sec_users.user_id','left');
        $this->db->from('sec_companyaccess');
        $this->db->where("sec_companyaccess.user_id", $ids);

        $count = $this->db->count_all_results();
    
        if( $count > 0 && $limit > 0) {
              $total_pages = ceil($count/$limit);
        } else {
              $total_pages = 0;
        }
        
        if ($page > $total_pages) $page=$total_pages;
        
        $start = $limit * $page - $limit;
        
        if($start <0) $start = 0;        
        
        
        $this->db->select("sec_companyaccess.company_access_id as pkey,sec_companyaccess.company_access_id, maint_company.company_code,
                        maint_company.company_name,sec_companyaccess.company_id,sec_companyaccess.user_id");
        $this->db->order_by($sidx,$sord);        
        $query = $this->db->get("sec_companyaccess");
        
        $this->db->flush_cache();
        $data['db'] = $query;        
        $data['page'] = $page;
        $data['totalpages'] = $total_pages;
        $data['totalrecords']=$count;
        return $data;            
    }

any suggestion will help me..

thanks
#2

[eluser]danmontgomery[/eluser]
So... What's the problem?
#3

[eluser]kikz4life[/eluser]
when i try to call the function getDetailList in the controller it gives me an array. What i want to do is just get the $ids in the function getDetailList($ids).
For more clarifcation i tried using this in my controller
$this->User->getDetailList($ids); but this return an array.

My Controller:
Code:
$data2['company_id'] = $this->db->insert_id();
                    $ids = $this->input->post('user_id');
    
                    $data2['user_id']= $this->User->getDetailList($ids);
                    $this->db->insert('sec_companyaccess',$data2);}

error found in my firebug:
Code:
Unknown column 'Array' in 'field list'</p><p>INSERT INTO `erp_sec_companyaccess` (`company_id`, `user_id`) VALUES (2, Array)




Theme © iAndrew 2016 - Forum software by © MyBB