Different databases for one limesurvey system?

More
4 years 8 months ago #91987 by jesovn
jesovn created the topic: Different databases for one limesurvey system?
Hi, I'm actually developing an application that uses Limesurvey.

This application needs different databases, one for each "department".

I've created different LimeSurvey databases. For that, I modify the Surveys URL, adding a parameter to this URL. Looks like this:

http://localhost/proyect/limesurvey/index.php/survey/index/sid/189169/token/f66y3gkdhdgnwt?departmentid=1

The "index.php" stores in SESSION the "departmentID", and then the "config.php" reads this SESSION variable to switch between different databases. It works for doing the surveys, and if I want to enter into the admin page it also works with this URL:

http://localhost/proyect/limesurvey/index.php/admin?departmentid=1

But with the remotecontrol2 it doesn't work. My application stores in SESSION the departmentID, but when I use the RemoteControl I can't get the sessionKey (there's an exception).

I'd like to know how I could configure the remotecontrol to switch between different databases like in the other use. Or if it is possible to send this parameter to the remotecontrol....

Please help, the only other solution is to have a limesurvey proyect for each department. I know that it isn't an usual use of limesurvey... but could be nice to modify Limesurvey to have this capability.

Thanks in advance! Best regards,
Jesus

Please Log in to join the conversation.

More
4 years 8 months ago - 4 years 8 months ago #92023 by DenisChenu
DenisChenu replied the topic: Different databases for one limesurvey system?
Hello,

With different server name, it's "relative" easy.

You can test the server name in config.phpo and set the detabase according to the servername.

For example:
$thishost=$_SERVER['HTTP_HOST'];
if($thishost=="localhost"){
  $connectionString='mysql:host=localhost;port=3306;dbname=ls_localhost;'
}else{
  $connectionString='mysql:host=localhost;port=3306;dbname=ls_web;'
}

And change the array with:
'components' => array(
		'db' => array(
			'connectionString' => $connectionString,

Here, LS use is own session_name, think it's difficult to tak session var from another session before using session of LimeSurvey.

Maybe another idea is to have symbolic link for limesurvey directory and test the dirname of config.php to set the $connectionString.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
Last Edit: 4 years 8 months ago by DenisChenu. Reason: remove extra "
The following user(s) said Thank You: jesovn

Please Log in to join the conversation.

More
4 years 8 months ago #92036 by jesovn
jesovn replied the topic: Different databases for one limesurvey system?
Thank you DenisChenu!! I've solved it! =D Very useful!

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now