Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <?php if(!defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Login_model extends CI_Model
  4. {
  5.  
  6. /**
  7. * This function used to check the login credentials of the user
  8. * @param string $username : This is username of the user
  9. * @param string $password : This is encrypted password of the user
  10. */
  11. function loginMe($username, $password)
  12. {
  13. $this->db->select('BaseTbl.userId, BaseTbl.password, BaseTbl.name, BaseTbl.roleId, Roles.role, guru_matpel.id_matpel');
  14. $this->db->from('tbl_users as BaseTbl');
  15. $this->db->join('guru_matpel','guru_matpel.id_guru = BaseTbl.userId');
  16. $this->db->join('tbl_roles as Roles','Roles.roleId = BaseTbl.roleId');
  17. $this->db->where('BaseTbl.username', $username);
  18. $this->db->where('BaseTbl.password', MD5($password));
  19. $query = $this->db->get();
  20.  
  21. $user = $query->result();
  22.  
  23. if(!empty($user)){
  24. return $user;
  25. } else {
  26. return array();
  27. }
  28. }
  29.  
  30. function loginAdmin($username, $password)
  31. {
  32. $this->db->select('BaseTbl.userId, BaseTbl.password, BaseTbl.name, BaseTbl.roleId, Roles.role');
  33. $this->db->from('tbl_users as BaseTbl');
  34. $this->db->join('tbl_roles as Roles','Roles.roleId = BaseTbl.roleId');
  35. $this->db->where('BaseTbl.username', $username);
  36. $this->db->where('BaseTbl.password', MD5($password));
  37. $query = $this->db->get();
  38.  
  39. $user = $query->result();
  40.  
  41. if(!empty($user)){
  42. return $user;
  43. } else {
  44. return array();
  45. }
  46. }
  47.  
  48.  
  49. function lihat_tahunajaran(){
  50. $query = $this->db->get('tahun_ajaran')->result();
  51. return $query;
  52. }
  53.  
  54. /**
  55. * This function used to check username exists or not
  56. * @param {string} $username : This is users username id
  57. * @return {boolean} $result : TRUE/FALSE
  58. */
  59. function checkUsernameExist($username)
  60. {
  61. $this->db->select('userId');
  62. $this->db->where('username', $username);
  63. $query = $this->db->get('tbl_users');
  64.  
  65. if ($query->num_rows() > 0){
  66. return true;
  67. } else {
  68. return false;
  69. }
  70. }
  71. }
  72.  
  73. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement