<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Post_Level_Model extends CI_Model{
    
    public $table = 'post_level';
    
    public function __construct() {
        parent::__construct();
    }
    
    public function get( $psotLevel_ID = NULL ){
        if($psotLevel_ID==NULL){
                
            $query = $this->db->select('*')
                    ->from($this->table)                    
                    ->join('exam_org',$this->table.'.exam_org_ID=exam_org.exam_org_ID')
                    ->get();
            return $query->result();
        }
        $query = $this->db->select('*')
                    ->from($this->table)    
                    ->where($this->table.'.post_level_ID', $psotLevel_ID)                
                    ->join('exam_org',$this->table.'.exam_org_ID=exam_org.exam_org_ID')
                    ->get();
        return $query->row();
    }

    public function get_where_exam_org($examOrgID)
    {
        $query = $this->db->get_where( 'post_level',array('exam_org_ID' => $examOrgID));
        return $query->result();
    }
    
    public function insert(){
        $data = array(
                'post_level_name ' => $this->input->post('post_level'),
                'exam_org_ID ' => $this->input->post('exam_org_ID')
                );

		return $this->db->insert($this->table,$data);
    }
    
    public function update(){
        $data = array(
		'post_level_name' => $this->input->post('post_level'),
                'exam_org_ID' => $this->input->post('exam_org_ID'),
		);
		$this->db->where('post_level_ID', $this->input->post('post_level_ID'));
                //echo $this->db->last_query();
		return $this->db->update($this->table,$data);
    } 
    
    public function delete($post_level_ID = NULL){
        return $this->db->delete( $this->table, array('post_level_ID' => $post_level_ID ));
    }
}


