<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Login_model extends CI_Model 
{
	var $user_master = TBL_USERS;   
	var $ula_table = TBL_USER_LOGIN_ATTEMPS; 

	public function update_user_data($where, $data)
	{
		$this->db->update($this->user_master, $data, $where);
		return $this->db->affected_rows();
	} 

	public function save_user_data($data)
	{
		$this->db->insert($this->user_master, $data);
		return $this->db->insert_id();
	}  

	public function save_ula_data($data)
	{
		$this->db->insert($this->ula_table, $data);
		return $this->db->insert_id();
	} 

	 

	public function update($where, $data)
	{
		$this->db->update($this->user_master, $data, $where);
		return $this->db->affected_rows();
	}

	function get_by_id($id) 
	{
		$this->db->select("u.*");
		$this->db->where('u.id', $id);   
        $query = $this->db->get(TBL_USERS . ' u');
        if ($query->num_rows() > 0) {
            return $query->row();
        }
        return FALSE;
    }
}