Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class AccountsDbConnection extends CDbConnection
- {
- public $host;
- public $type;
- public $baseName;
- public $keys = array(
- 'user' => null,
- 'pass' => null,
- 'db' => null,
- );
- public function init()
- {
- $this->username = $this->getKey('user');
- $this->password = $this->getKey('pass');
- $db = $this->getKey('db');
- $this->connectionString = strtr('{type}:host={host};dbname={baseName}{db}', array(
- '{type}' => $this->type,
- '{host}' => $this->host,
- '{baseName}' => $this->baseName,
- '{db}' => $db,
- ));
- return parent::init();
- }
- protected function getKey($index)
- {
- // ... return value stored in session
- }
- }
Add Comment
Please, Sign In to add comment