Advertisement
Guest User

Untitled

a guest
Feb 7th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <?php
  2.  
  3. class Database extends CI_Controller {
  4.  
  5. public $branch_db;
  6.  
  7. function __construct($company_name, $branch_name) {
  8.  
  9. parent::__construct();
  10.  
  11. $branch_db = $this->load->database($company_name.'_db_'.$branch_name);
  12. }
  13. }
  14. ?>
  15.  
  16. protected function verifyLogin($username, $password) {
  17.  
  18. $this->db->trans_start();
  19.  
  20. $sql = "SELECT password, company_id, branch_id
  21. FROM account
  22. WHERE username = {$username}"; //Prepare statement
  23.  
  24. $query = $this->db->query($sql);
  25. $result_num = $query->num_rows();
  26.  
  27. if ($result_num == 1) {
  28. $first_row = $query->row();
  29. $stored_password = $first_row->password;
  30.  
  31. if (password_verify($password, $stored_password)) {
  32. //Successful login
  33. //Get company name
  34. //Get branch name
  35. //Set database
  36. //Pass company_name, branch_name
  37. //All models must be able to access the dynamically loaded database
  38. }
  39.  
  40. }
  41.  
  42. $this->db->trans_complete();
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement