Welcome, Guest
Username: Password: Remember me

TOPIC: Different databases for one limesurvey system?

Different databases for one limesurvey system? 1 year 8 months ago #91987

  • jesovn
  • jesovn's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
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
The administrator has disabled public write access.

Re: Different databases for one limesurvey system? 1 year 8 months ago #92023

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6451
  • Thank you received: 844
  • Karma: 249
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
Last Edit: 1 year 8 months ago by DenisChenu. Reason: remove extra "
The administrator has disabled public write access.
The following user(s) said Thank You: jesovn

Re: Different databases for one limesurvey system? 1 year 8 months ago #92036

  • jesovn
  • jesovn's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
Thank you DenisChenu!! I've solved it! =D Very useful!
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.207 seconds
Donation Image