Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database extends CI_Controller {
- public $branch_db;
- function __construct($company_name, $branch_name) {
- parent::__construct();
- $branch_db = $this->load->database($company_name.'_db_'.$branch_name);
- }
- }
- ?>
- protected function verifyLogin($username, $password) {
- $this->db->trans_start();
- $sql = "SELECT password, company_id, branch_id
- FROM account
- WHERE username = {$username}"; //Prepare statement
- $query = $this->db->query($sql);
- $result_num = $query->num_rows();
- if ($result_num == 1) {
- $first_row = $query->row();
- $stored_password = $first_row->password;
- if (password_verify($password, $stored_password)) {
- //Successful login
- //Get company name
- //Get branch name
- //Set database
- //Pass company_name, branch_name
- //All models must be able to access the dynamically loaded database
- }
- }
- $this->db->trans_complete();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement