Working with Multiple Databases

From Aikiframework wiki

Jump to: navigation, search

usually a normal Sql query look like:

select * from tablename

developers can also specify the database name in the query

select * from database.tablename

in both cases a connection to that database should exist in order for the query to run.

if you use the same username and password that are specified in config.php in another database you can directly run a query like:

select * from database2.tablename2

but what if database2 is on different server and/or has different username and password?

aiki solves this problem, with a feature called allow multiple_databases you can enable it by changing the value of

$config["allow_multiple_databases"]

in config.php to true. you can from admin panel database & forms insert the connection information for database2 in aiki_databases and aiki will handle the connections to different databases without any further interaction so a query like:

select * from database2.tablename2

will just work if the connection information of database2 exists in aiki_databases