Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*******************************************************************************
- * Database_Mysql.php
- *
- * MySQL Wrapper to allow access into other databases (only with Seagull)
- *
- * Michael McMullen <[email protected]>
- *******************************************************************************/
- require_once SGL_LIB_DIR .'/SGL/DB.php';
- class Database_Mysql
- {
- var $username;
- var $password;
- var $hostname;
- var $database;
- var $dbh;
- var $old_connection;
- function Database_Mysql($username, $password, $hostname, $database)
- {
- $this->username = $username;
- $this->password = $password;
- $this->hostname = $hostname;
- $this->database = $database;
- }
- function connect(&$dbh)
- {
- $this->old_connection = $dbh->dsn['dbsyntax'] .'://'. $dbh->dsn['username'] .':'. $dbh->dsn['password'] .'@'. $dbh->dsn['socket'] .'/'. $dbh->dsn['database'];
- // Load DataObjects
- $options = &PEAR::getStaticProperty('DB_DataObject','options');
- // Overwrite Connection
- $conn = 'mysql://'. $this->username .':'. $this->password .'@'. $this->hostname .'/'. $this->database;
- $options['database'] = $conn;
- // Change Database
- $dbh =& SGL_DB::singleton($conn);
- }
- function disconnect(&$dbh)
- {
- // Load DataObjects
- $options = &PEAR::getStaticProperty('DB_DataObject','options');
- // Overwrite Connection
- $conn = $this->old_connection;
- $options['database'] = $conn;
- $dbh =& SGL_DB::singleton($conn);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment