<?php defined('BASEPATH') OR exit('No direct script access allowed');

/**
* Subject Model
*/

class Subject_Model extends CI_Model{

	public $table = 'subject';

	public function __construct()
		{
			parent::__construct();
		}

	public function insert(){

		$data = array(
			'subject_name' => $this->input->post('subjects')
			);

		return $this->db->insert($this->table,$data);
	}

	public function update(){
		$data = array(
			'subject_name' => $this->input->post('subjects')
		);
		$this->db->where('subject_ID', $this->input->post('subject_id'));
		return $this->db->update($this->table,$data);
	}

	public function get( $subject_ID = null){
		if($subject_ID==null){
			$query = $this->db->get($this->table);
			return $query->result();
		}
		$query = $this->db->get_where($this->table,array('subject_ID' => $subject_ID));
		return $query->row();
	}

	public function delete($subject_ID = null){
		return $this->db->delete($this->table, array('subject_ID' => $subject_ID ));
	}


}