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

    public function get_where_exam_standard($examStandardID)
    {
        $query = $this->db->get_where( 'exam_org',array('exam_standard_ID' => $examStandardID));
        return $query->result();
    }
    
    public function insert()
    {
        $data = array(
                'exam_org_name ' => $this->input->post('exam_org'),
                'exam_standard_ID ' => $this->input->post('exam_standard_ID')
                );

		return $this->db->insert($this->table,$data);
    }
    
    public function update(){
        $data = array(
		'exam_org_name' => $this->input->post('exam_org_name'),
                'exam_standard_ID' => $this->input->post('exam_standard_ID'),
		);
		$this->db->where('exam_org_ID', $this->input->post('exam_org_ID'));
		return $this->db->update($this->table,$data);
    }  
    
    
    public function delete($exam_org_ID = NULL){
        return $this->db->delete( $this->table, array('exam_org_ID' => $exam_org_ID ));
    }

}
