Forums | Mahara Community
Multiple Databases for Mahara
01 September 2016, 19:59
Thank you for your reply for the last question. Again i'm back with interesting new question. Scalability for the Mahara system that explained at wiki.mahara.org/wiki/System_Administrator%27s_Guide/Scalability is excllent and we understood clearly. Our new question is Scalability at Database end. We are developing new Blocktype plugin like Wall and we need to keep all those data in new database server (separate CPU box from the Mahara DB server). This plugin will receive large data from external application and will be used as artefact in mahara. So is it possible to use 2 Databases in Mahara to scale up?
Thank you in advance, cheers!
08 September 2016, 17:14
Any response on this question? Please update.
09 September 2016, 15:56
In regards to scalability at the database end.
Mahara doesn't handle the connection to more than one database.
But in theory it should be possible to have a function within your blocktype plugin that make a new db connection object to a different database.
See around 'ADONewConnection()' in init.php
You could make a new connection instance, say $newdb, and then do reads/writes to it.
Note: you'd have to do db querys directly and not with mahara's db functions
$stmt = $newdb->Prepare($sql);
On saying this we've done something similar here at Catalyst when we wrote a bunch of scripts to help migrate data from one mahara site into another mahara site as an institution that included a dbtoggler class, which holds the instances of source and target db instances, so we could switch back and forth from source db / target db and run a bunch of commands easily.
But by the sounds of things the blocktype will be the only thing accessing the new database so you might not need the overkill of a dbtoggler.
I imagine all you would need is:
Have $newdb connection fetch relevant results and then display them via php and/or save some info in mahara db based on the results from $newdb rather than saving $newdb data into mahara $db directly.
I might see if I can whip up a simple dbtoggler example if I have time one day soon but while you wait I believe we created our dbtoggler based on some Moodle code so you could also look at their codebase for inspiration as well.
10 September 2016, 18:38
Thank you Robert. I will try the code and share here if interesting.