Revision 1974
Added by darkviper about 12 years ago
| WbDatabase.php | ||
|---|---|---|
| 40 | 40 | 
     | 
| 41 | 41 | 
    private $_db_handle = null; // readonly from outside  | 
| 42 | 42 | 
    private $_db_name = '';  | 
| 43 | 
    private $_sInstanceIdentifier = '';  | 
|
| 43 | 44 | 
    protected $sTablePrefix = '';  | 
| 44 | 45 | 
    protected $sCharset = '';  | 
| 45 | 46 | 
    protected $connected = false;  | 
| ... | ... | |
| 59 | 60 | 
    	public static function getInstance($sIdentifier = 'core') {
   | 
| 60 | 61 | 
    		if( !isset(self::$_oInstances[$sIdentifier])) {
   | 
| 61 | 62 | 
    $c = __CLASS__;  | 
| 62 | 
    self::$_oInstances[$sIdentifier] = new $c;  | 
|
| 63 | 
    $oInstance = new $c;  | 
|
| 64 | 
    $oInstance->_sInstanceIdentifier = $sIdentifier;  | 
|
| 65 | 
    self::$_oInstances[$sIdentifier] = $oInstance;  | 
|
| 63 | 66 | 
    }  | 
| 64 | 67 | 
    return self::$_oInstances[$sIdentifier];  | 
| 65 | 68 | 
    }  | 
| ... | ... | |
| 83 | 86 | 
    * Example for SQL-Url: 'mysql://user:password@demo.de[:3306]/datenbank'  | 
| 84 | 87 | 
    */  | 
| 85 | 88 | 
    	public function doConnect($url = '') {
   | 
| 89 | 
    		if($this->connected) { return $this->connected; } // prevent from reconnecting
   | 
|
| 86 | 90 | 
    $this->connected = false;  | 
| 87 | 91 | 
    		if($url != '') {
   | 
| 88 | 92 | 
    $aIni = parse_url($url);  | 
| ... | ... | |
| 137 | 141 | 
     | 
| 138 | 142 | 
    // Disconnect from the database  | 
| 139 | 143 | 
    	public function disconnect() {
   | 
| 140 | 
    		if($this->connected==true) {
   | 
|
| 144 | 
    		if($this->connected == true && $oInstance->_sInstanceIdentifier != 'core' ) {
   | 
|
| 141 | 145 | 
    mysql_close($this->_db_handle);  | 
| 146 | 
    $this->connected = false;  | 
|
| 142 | 147 | 
    return true;  | 
| 143 | 
    		} else {
   | 
|
| 144 | 
    return false;  | 
|
| 145 | 148 | 
    }  | 
| 149 | 
    return false;  | 
|
| 146 | 150 | 
    }  | 
| 147 | 151 | 
     | 
| 148 | 152 | 
    // Run a query  | 
| ... | ... | |
| 227 | 231 | 
    case 'getTablePrefix':  | 
| 228 | 232 | 
    $retval = $this->sTablePrefix;  | 
| 229 | 233 | 
    break;  | 
| 234 | 
    case 'QueryCount':  | 
|
| 230 | 235 | 
    case 'getQueryCount':  | 
| 231 | 236 | 
    $retval = $this->iQueryCount;  | 
| 232 | 237 | 
    break;  | 
Also available in: Unified diff
/framework/WbDatabase fixed little problem with multiple database connections