Guest User

Untitled

a guest
Feb 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2. class AccountsDbConnection extends CDbConnection
  3. {
  4. public $host;
  5.  
  6. public $type;
  7.  
  8. public $baseName;
  9.  
  10. public $keys = array(
  11. 'user' => null,
  12. 'pass' => null,
  13. 'db' => null,
  14. );
  15.  
  16.  
  17. public function init()
  18. {
  19. $this->username = $this->getKey('user');
  20. $this->password = $this->getKey('pass');
  21. $db = $this->getKey('db');
  22.  
  23. $this->connectionString = strtr('{type}:host={host};dbname={baseName}{db}', array(
  24. '{type}' => $this->type,
  25. '{host}' => $this->host,
  26. '{baseName}' => $this->baseName,
  27. '{db}' => $db,
  28. ));
  29.  
  30. return parent::init();
  31. }
  32.  
  33. protected function getKey($index)
  34. {
  35. // ... return value stored in session
  36. }
  37.  
  38. }
Add Comment
Please, Sign In to add comment