Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if(!defined('BASEPATH')) exit('No direct script access allowed');
- class Login_model extends CI_Model
- {
- /**
- * This function used to check the login credentials of the user
- * @param string $username : This is username of the user
- * @param string $password : This is encrypted password of the user
- */
- function loginMe($username, $password)
- {
- $this->db->select('BaseTbl.userId, BaseTbl.password, BaseTbl.name, BaseTbl.roleId, Roles.role, guru_matpel.id_matpel');
- $this->db->from('tbl_users as BaseTbl');
- $this->db->join('guru_matpel','guru_matpel.id_guru = BaseTbl.userId');
- $this->db->join('tbl_roles as Roles','Roles.roleId = BaseTbl.roleId');
- $this->db->where('BaseTbl.username', $username);
- $this->db->where('BaseTbl.password', MD5($password));
- $query = $this->db->get();
- $user = $query->result();
- if(!empty($user)){
- return $user;
- } else {
- return array();
- }
- }
- function loginAdmin($username, $password)
- {
- $this->db->select('BaseTbl.userId, BaseTbl.password, BaseTbl.name, BaseTbl.roleId, Roles.role');
- $this->db->from('tbl_users as BaseTbl');
- $this->db->join('tbl_roles as Roles','Roles.roleId = BaseTbl.roleId');
- $this->db->where('BaseTbl.username', $username);
- $this->db->where('BaseTbl.password', MD5($password));
- $query = $this->db->get();
- $user = $query->result();
- if(!empty($user)){
- return $user;
- } else {
- return array();
- }
- }
- function lihat_tahunajaran(){
- $query = $this->db->get('tahun_ajaran')->result();
- return $query;
- }
- /**
- * This function used to check username exists or not
- * @param {string} $username : This is users username id
- * @return {boolean} $result : TRUE/FALSE
- */
- function checkUsernameExist($username)
- {
- $this->db->select('userId');
- $this->db->where('username', $username);
- $query = $this->db->get('tbl_users');
- if ($query->num_rows() > 0){
- return true;
- } else {
- return false;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement