I am using your great class to query my DBs.
Unfortunately I have to interact with multiple databases with different USER and PASSOWRD.
Instead of creating copies of the config.php file, how I can override a variable:
|2010-06-09 16:10:20 - In reply to message 1 from Valentino Lauciani|
|Hi Valentino, thanks for your feedback :) |
Unfortunately you can't do this with this class unless you modify it. (A lot). Why? Because only 1 db instance can be invoked with this class so trying to connect simultaneously to another with be pointless according to the class's basic principles.
If you really want to do this, I suggest taking out the DB_connect class and on the __construct method of the DB_mysql class adding this:
if (mysqli_connect_error()) die(mysqli_connect_error());
else $this->connected = TRUE;
creating the class as:
$myLink = new DB_mysql('host','user','pass','dbname'[,port]);
That should do the trick.
|2010-06-09 19:50:38 - In reply to message 2 from Camilo Sperberg|
|Hello and thanks for your reply.|
If I understand correctly, you're telling me that a solution might be to copy the class "DB_Connect" in a new file (for example db_connect.php) and then change its constructor?
When you said "on the __construct method of the class DB_mysql adding" what class do you mean? Class "DB_Connect" into new file db_connect.php?
Thank you and sorry for requesting clarification.
|2010-06-10 03:52:08 - In reply to message 3 from Valentino Lauciani|
|oh no no no ... if you look carefully, you can see that the package are 2 classes. You should just (only) delete the DB_connect class. If you want to connect to multiple databases, that class (which avoids cloning AKA establishing another connection) is useless to you. |
So, you should just delete it.
In the remaining class, you should apply on the __construct method all the changes previously exposed.
|2010-06-10 08:26:48 - In reply to message 4 from Camilo Sperberg|
|Thank you very very much.|