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

class LoginModel extends CI_Model{

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

	function checkLogin($user_name, $pass){
		$this->db->where('user_name', $user_name);
		$this->db->where('password', $pass);
		$query = $this->db->get('admin_table');
		if($query){
			return $query->row_array();
		}else{
			return false;
		}
	}

	function logged_status($table, $data, $where){
		$this->db->set($data);
        $this->db->where($where);
		if($this->db->update($table, $data)){
			return true;
		}else{
			return false;
		}
	}


	function selectInfo($staff_tb, $where){

		if($where){
		$this->db->where($where);
	}

			$sql ="SELECT 	creator_id,user_name,PASSWORD,full_name, mobile, user_role, STATUS, CURRENT_TIME,creator_id_fk FROM admin_table ;";

		$query = $this->db->query($sql);


	if($query){

//	print_r($query->result()); die;

	return $query->result();

	}else{
		return false;
	}


}


				// insert Query For Insert Data

public function insertInfo($table, $data) {
	if ($this->db->insert($table, $data)) {
					$insert_id = $this->db->insert_id();
		return $insert_id;
	}else{
		return false;
	}
}


		function getInfoById($id){

		 $sql ='SELECT 	creator_id,user_name,PASSWORD,full_name, mobile, user_role, STATUS, CURRENT_TIME, creator_id_fk,slider,news,event,staff,gallery,subgallery,career,inquiry,user FROM admin_table WHERE creator_id ="'.$id.'" ';

		$query = $this->db->query($sql);

	 //	print_r($query->result()); die;
				$result = $query->result();
	return $result;
}


// Update Query For Selected Student
function updateInfoById($id,$data){
$this->db->where('creator_id', $id);
$this->db->update('admin_table', $data);
}

function deleteInfo($id)
{

$sql ='DELETE FROM admin_table WHERE creator_id= "'.$id.'"; ';
//print_r(base_url("GalleryImages/".$id.".png")); die;
 //unlink(base_url("GalleryImages/".$id));
$this->db->query($sql);
}

}

?>
