Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change database on web gui #104

Open
xviom opened this issue Mar 25, 2019 · 2 comments
Open

change database on web gui #104

xviom opened this issue Mar 25, 2019 · 2 comments

Comments

@xviom
Copy link

xviom commented Mar 25, 2019

Hi,
i've some databases declared in config.php and working ok:
http://localhost/robinhood/api/db_info
{
"2": {
"DB_TYPE": "mysql",
"DB_HOST": "robinhood.local",
"DB_NAME": "robinhood_2_dataset",
"DB_USER": "robinhood",
"DB_PASSWD": "",
"DB_USAGE": [
"data",
"config"
],
"DB_STATUS": "Ok"
},
"1": {
"DB_TYPE": "mysql",
"DB_HOST": "robinhood.local",
"DB_NAME": "robinhood_1_dataset",
"DB_USER": "robinhood",
"DB_PASSWD": "
",
"DB_USAGE": [
"data",
"config"
],
"DB_STATUS": "Ok"
}
}

Is it possible to change/select another database to query another FS_Path?

@xviom
Copy link
Author

xviom commented Mar 25, 2019

I mean:

I would like to change CURRENT_DB global var from api URL, to automate queries from an external tool developed by our team.

For example:
http://myrobinhood.com/api/DB/...

thanks

@xviom
Copy link
Author

xviom commented Mar 27, 2019

problem solved!
Prerequisites: database definition and apache Aliases must be the same string.

  • modifing config.php and changing CURRENT_DB

//Set defaut DB as current
//$CURRENT_DB = $DEFAULT_DB;
$CURRENT_DB = preg_replace("/[^A-Z]+/", "",$_SERVER['REQUEST_URI']);

  • and then adding some Aliases (matching the REQUEST_URI) to robinhood.conf to the same DocumentRoot.

an example:

  1. define all db entries in your <config.php>
    /*****************************
  •    Database            *
    

*****************************/
$YOU_DB = "YOU";
$SHE_DB = "SHE";
$THEY_DB = "THEY";
...
declare all databases
...
in the end of the file modify CURRENT_DB
$CURRENT_DB = preg_replace("/[^A-Z]+/", "",$_SERVER['REQUEST_URI']);

  1. add below lines into virtualhost config file <robinhood.conf>
    ...
    Alias /YOU /var/www/robinhood
    Alias /SHE /var/www/robinhood
    Alias /THEY /var/www/robinhood
    Alias /robinhood /var/www/robinhood (you can remove this line)
    ...

  2. finish,

now, all dbs instances are referenced by one web-gui installation, you can check the content of every partition throught:

http://myrobinhood.com/YOU
http://myrobinhood.com/SHE
http://myrobinhood.com/THEY.

voilà!

I don't know if this the best solution, but works for me.
see you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant