<?php 

/**
 * SharedController Controller
 * @category  Controller / Model
 */
class SharedController extends BaseController{
	
	/**
     * user_username_value_exist Model Action
     * @return array
     */
	function user_username_value_exist($val){
		$db = $this->GetModel();
		$db->where("username", $val);
		$exist = $db->has("user");
		return $exist;
	}

	/**
     * user_email_value_exist Model Action
     * @return array
     */
	function user_email_value_exist($val){
		$db = $this->GetModel();
		$db->where("email", $val);
		$exist = $db->has("user");
		return $exist;
	}

	/**
     * data_buku_kategori_option_list Model Action
     * @return array
     */
	function data_buku_kategori_option_list(){
		$db = $this->GetModel();
		$sqltext = "SELECT  DISTINCT kategori_buku AS value,kategori_buku AS label FROM kategori_buku ORDER BY id";
		$queryparams = null;
		$arr = $db->rawQuery($sqltext, $queryparams);
		return $arr;
	}

	/**
     * getcount_databuku Model Action
     * @return Value
     */
	function getcount_databuku(){
		$db = $this->GetModel();
		$sqltext = "SELECT COUNT(*) AS num FROM data_buku";
		$queryparams = null;
		$val = $db->rawQueryValue($sqltext, $queryparams);
		
		if(is_array($val)){
			return $val[0];
		}
		return $val;
	}

	/**
     * getcount_kategoribuku Model Action
     * @return Value
     */
	function getcount_kategoribuku(){
		$db = $this->GetModel();
		$sqltext = "SELECT COUNT(*) AS num FROM kategori_buku";
		$queryparams = null;
		$val = $db->rawQueryValue($sqltext, $queryparams);
		
		if(is_array($val)){
			return $val[0];
		}
		return $val;
	}

	/**
     * getcount_kodebuku Model Action
     * @return Value
     */
	function getcount_kodebuku(){
		$db = $this->GetModel();
		$sqltext = "SELECT COUNT(*) AS num FROM kode_buku";
		$queryparams = null;
		$val = $db->rawQueryValue($sqltext, $queryparams);
		
		if(is_array($val)){
			return $val[0];
		}
		return $val;
	}

	/**
     * getcount_user Model Action
     * @return Value
     */
	function getcount_user(){
		$db = $this->GetModel();
		$sqltext = "SELECT COUNT(*) AS num FROM user";
		$queryparams = null;
		$val = $db->rawQueryValue($sqltext, $queryparams);
		
		if(is_array($val)){
			return $val[0];
		}
		return $val;
	}

}
