Editor 1.3.1 connect to Multiple Databases
Editor 1.3.1 connect to Multiple Databases
I am trying the new version of Editor. Is it possible to have have connections to multiple databases, all on the same server, and all with the same username/password? The config.php file allows for only one connection.
With reference to the discussion here, you said to add a new database like this:
$data = Editor::inst( $db, 'dt.releases' )
Following this, if I understand correctly, in the config.php file I have a connection to Datatbase1. In my php server-side script, taken from one of the Examples, I have a connection to a table in Datatbase1, as follows:
Editor::inst( $db, 'Table1' )
For another table, if I want to use a different database, ie Database2, where do I call the table for Database2? I tried this, but it did not work
Editor::inst( $db, 'dt.Database2', 'Table22' )
many thanks,
Ken
Replies
The config.php file does yes, but you can create as many instances of the database class as you wish, using the same method as the config.php file. You would just assign the second database to another variable -
$db2
or whatever!However, if your login user for the database has access privileges for both databases, you can indeed just use a database qualifier as you suggest. I do that myself for joining two tables which are in two different MySQL databases, but which the user has access to read.
In the example you give, for SQL the left hand side is more specific, so it goes
database.table.field
(which parts left out as needed). So you might have:which will access
Table22
in theDatabase2
schema.Allan
Perfect. Thanks.