<?php 
class User_model extends CI_Model {
	public function _consruct(){
		parent::_construct();
 	}
		
 	function getAdminData($user_id = ''){
 		if(empty($user_id)){
 			return 0;
 		}
 		
		$query = $this->db->get_where('admin',array('id'=>$user_id));

		if($query->num_rows() > 0 && !empty($query)){
			$result = $query->row();
            return $result;
			
			}
			return 0;
			
		}

 	function updateUser($user_id = '',$user_data = array()){
 		if(empty($user_id) || empty($user_data)){
 			return 0;
 		}

	
 			$userData['username'] = $user_data['username'];
 			
 			if(isset($user_data['password']) && !empty($user_data['password'])){
 				$userData['password'] = $user_data['password'];
 			}
 			if(isset($user_data['profile_image']) && !empty($user_data['profile_image'])){
 				$userData['profile_picture'] = $user_data['profile_image'];
 			}
 			
 			$this->db->update('admin',$userData,array('id'=>$user_id));

			if(!empty($usrData)){
				$this->session->set_userdata('id',$usrData->id);
				
				$this->session->set_userdata('username',$usrData->username);
				$this->session->set_userdata('logged_in','1');
				$this->session->set_userdata('user_type','1');
			}
			return 1;
 		}
 	
}
?>