Multiple database names ?

Asked by osthafen

How is it possible to adress mutliple databases from within phpdevshell ?

Let's say I've got the System DB under this configuration:

$configuration['database_name'] = 'phpdev';
$configuration['database_user_name'] = 'root';
$configuration['database_password'] = 'root';

And for my project I would like to have a different database_name.
Is this possible ?

Thank you very much!


Question information

English Edit question
PHPDevShell Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Revision history for this message
Greg (gregfr) said :

It's possible to change the database *name*, i.e. use a single database with another name.
Currently however you can only declare one database, i.e. all queries will be sent to a single database.
In a future version that will be possible.

Revision history for this message
osthafen (osthafen) said :

Thank you!

I was hoping I could do something like

$second_db = new PHPDS_PDOconnector;

and declare a second (or third...) database.

Revision history for this message
Don Schoeman (don.sch) said :

Hi martin, as to your first question (How is it possible to adress mutliple databases from within phpdevshell):

First we just need to know why this is required? For example, if you are planning on running multiple websites from one source (using Virtual Hosts) you can use the multi-host.config.php to setup a unique configuration for each virtual host. Open the multi-host.config.php and it should become clearer to you.

If you literally want to access multiple databases in a single session it is going to be a little more difficult because phpdevshell currently only supports the access of one database for itself. However, that does not stop you from calling other databases using the standard PHP database functions, such as mysql_connect() and pg_connect() in your own code. You can even add your own custom $configuration[] options into the PHPDS-defaults.config.php file for your custom database connection.

I had to do this once in the past for a PostgreSQL database that was sitting on another server and for which I had to pull data and display it within PHPDevShell. So yes, it is possible to connect to more than one database at a time.

Revision history for this message
osthafen (osthafen) said :

OK I'll use the standard PHP database functions.

Thanks a lot!

Revision history for this message
Greg (gregfr) said :

In fact you can use PDO or any other abstraction layer and/or use standard functions ; you just won't have the power the PHPDS_query class.
But don't worry, the database system has been design with that in mind, so it will be added in a future version.