Advertisement
Guest User

Untitled

a guest
Jun 4th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. <?php
  2. if (!defined('BASEPATH')) exit('No direct script access allowed');
  3. require_once(DIR_LIB . "Database/DatabaseManager.php");
  4.  
  5. class ChangeDatabase{
  6.    
  7.     function changeToRead(){
  8.         $CI =& get_instance();
  9.         $database = DatabaseManager::initDatabase();
  10.        
  11.         //if it's a 'superuser'
  12.         if($superuser){
  13.  
  14.             $user = &$database->getUsername();
  15.             $active_group = &$database->getActiveGroup();
  16.             $active_group = "group_vision";
  17.             $user = "user_vision";
  18.            
  19.             //the database pass is returned by the user informed
  20.             $database->setPassword($user);
  21.             $referencePass = &$database->getPassword();
  22.                
  23.             $LumConnManager = Lumine_ConnectionManager::getInstance();
  24.             $LumConfList = $LumConnManager->getConfigurationList();
  25.             $lumineConfig = current($LumConfList);
  26.            
  27.             $lumineConfig->connection->setPassword($referencePass);
  28.             $lumineConfig->connection->setUser($user);
  29.            
  30.             //override the db original object
  31.             try{
  32.                 $dbObject = DB($active_group);
  33.                 $CI->db = $dbObject;
  34.             }catch(Exception $e){
  35.                 throw($e);
  36.             }
  37.            
  38.         }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement