11-26-2007, 09:32 PM
|
#7 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
I have like this...
php Code:
class DBmysql implements iDB { private $host; private $user; private $pass; private $data; public $table = array(); public $col = array(); public function setHandler ($host, $user, $pass, $data) { $this-> host = $host; $this-> user = $user; $this-> pass = $pass; $this-> data = $data; return $this; } public function connect () { @ mysql_connect($this-> host, $this-> user, $this-> pass) or die("Could not connect to the database."); return $this; } public function select () { @ mysql_select_db($this-> data) or die("Could not select database."); return $this; }etc....
So you just do like this to call it:
php Code:
$tanaxia['database'] = DB::getInstance($tanaxia['config']['database']['type']); $tanaxia['database']->setHandler( $tanaxia['config']['database']['host'], $tanaxia['config']['database']['user'], $tanaxia['config']['database']['pass'], $tanaxia['config']['database']['data'] ) ->connect() ->select();
All those variables are set in the config.php
And what you can do then, is to make a script that loads the database name from a .txt file
And then another script that allows you to change that value.
So your $tanaxia['config']['database']['data'] would be the value of the string in the .txt file ;)
Piece a cake :) or not xD
But that's the idea anyways.
|
|
|
|