• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I use again a function for another term?

#1
Controller 


    public function __construct() {
        parent::__construct();
        $this->load->model('HomeModel');
    }

    public function insertPostData() {
        $data['post_title']= $this->input->post('post_title');
        $data['post']= $this->input->post('post');
        $postImg= $_FILES['post_img']['name'];
        $Img_target_file="uploads/" .basename($postImg);
        if(file_exists($Img_target_file)){
            $Img_target_file="uploads/" . $data['post_img'] .basename($postImg);
        }
        move_uploaded_file($_FILES['post_img']['tmp_name'], $Img_target_file);
        $data['post_img']=$Img_target_file;
//        var_dump($data);
//        die();
        $insertId= $this->HomeModel->postData('article',$data);
        if($insertId){
            redirect(site_url('Admin/dashboard'));
        }
    }


Model


class HomeModel extends CI_Model {
    
    public function postData($table=null, $data=null) {
        $this->load->database();
        $this->db->insert($table,$data);
        return $this->db->insert_id();
    }
}




I want to use my insertPostData again for my another term. how can i do that?
Reply


Messages In This Thread
How can I use again a function for another term? - by Rajuone - 08-28-2018, 11:05 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.