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

/**
* Name			: QueryLib
* Created By	: Indra Hasan
* Created Date	: 27-9-2015
* Modified By	:
* Modified Date	:
* Description	: Libraries For Query database and system  
**/

class QueryLib {
	
	//delete row
	function _deleteRow($table,$where = "") {
		if (!empty($where)) {
			$this->db->where($where);
		}
		
		$data = $this->db->delete($table);
		return $data;
	}
	
	//get one field value
	function _getOneValue($table,$field,$where = "") {
		
		$this->db->select("$field as val");
		$this->db->from($table);
		if (!empty($where)) {
			$this->db->where($where);
		}
		
		$data = $this->db->get()->val;
		return $data;
	
	}
	
	//update query
	function _updateQuery($table,$update,$where = "") {
		
		if (!empty($where)) {
			$this->db->where($where);
		}
		$data = $this->db->update($table,$update);
		return $data;		
		
	}
	
	//get numRow
	function _getRownum($table,$field,$where= "") {
		
		$this->db->select($field);
		$this->db->from($table);
		if (!empty($where)) {
			$this->db->where($where);
		}
		
		$data = $this->db->get()->num_rows();
		return $data;
		
	}
	
	
}

