<?php 

class Model_topic extends CI_Model 
{
    function save($data)
    {
        if($this->db->insert('topics',$data)){
          return TRUE;
        } else {
          return FALSE;
        }
    }
    
    function delete($id)
    {
        $delete = $this->db->delete('topics',array('id'=>$id));
        if($delete){
            return TRUE;
        }else{
            return FALSE;
        }
    }
    
    function update($id,$data)
    {
        $where="id = '".$id."'"; 
        $update = $this->db->update('topics', $data, $where); 
        
        if($update){
            return TRUE;
        }
        return FALSE;
    }
    
    function get_topics(){
        $data = array('categories.category_name','topics.*');
        $get = $this->db->select($data)->from('topics')->join('categories','categories.id=topics.category')->get();
        return $get->result();
    }

    function get_categories(){
        $get = $this->db->get('categories');
        return $get->result();
    }
}
Update model untuk modul topic
Update model untuk modul topic
