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

/**
* Subject Model
*/

class Setting_Model extends CI_Model{

	public $table = 'settings';

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

	public function insert(){

		$data = array(
			'settings_name' => trim($this->input->post('settings_name')),
            'settings_value' => $this->input->post('settings_value')
			);

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

	public function update(){
		$data = array(
            'settings_value' => $this->input->post('settings_value')
		);
		$this->db->where('settings_name', $this->input->post('settings_name'));
		return $this->db->update($this->table,$data);
	}

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

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


}