Announcement

Collapse
No announcement yet.

Changing MySQL DB Connection at run time

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Changing MySQL DB Connection at run time

    Hi

    I am using SC 7.1 and MySql 5.6.11 and PHP version 5.4.22

    I wanted to understand how to change the database connection during run time. Lets say that I want to have one single application which needs to connect to different database (however the tables and structure are going to be the same).

    Lets look at the following in my first screen I will have something like this

    Customer : <Dropdown / Combo box to list down the customer list>
    Login Name:
    Password :

    Now based on Customer; I want to be able to connect to different database schema in MySQL. Is that possible? Or is there any other workaround for this scenario.

    Your help would be highly appreciated.

    Regards
    Narayanan

  • #2
    I would appreciate if someone can answer this question please.

    Comment


    • #3
      It is only possible if you hack into the generated code (as far as I know). But you would get some problems if you want one person to connect with database 1 and one with database 2 at the same time as far as I can see...
      If you use advanced deployment you will see that in the generated code the name of the connection is placed <your application name>.php file.
      Example:
      $_SESSION['scriptcase']['grid_filestorage']['glo_nm_perfil'] = "";
      $_SESSION['scriptcase']['grid_filestorage']['glo_nm_path_prod'] = "/scriptcase/prod";
      $_SESSION['scriptcase']['grid_filestorage']['glo_nm_path_imagens'] = "/scriptcase/file/img";
      $_SESSION['scriptcase']['grid_filestorage']['glo_nm_path_imag_temp'] = "/scriptcase/tmp";
      $_SESSION['scriptcase']['grid_filestorage']['glo_nm_path_doc'] = "c:/storage";
      $_SESSION['scriptcase']['grid_filestorage']['glo_nm_conexao'] = "conn_oracle";

      So you would need to change the last session variable in your code somewhere..
      Be warned this is untested, may not work and is at your own risk...
      Last edited by rr; 03-03-2014, 09:17 AM.

      Comment


      • #4
        There is a macro for that

        sc_change_connection("Old_Connection", "New_Connection")

        Well explained in http://www.scriptcase.net/docs/en_us/manual_mp.htm

        So you have to develop using a "default" connection ad change dynamically in production.
        Never used but seems to be what you are searching.
        Giorgio Bravi
        Dolphin Software & Thinkware
        www.dolphin.it

        Comment


        • #5
          You can follow this thread

          http://www.scriptcase.net/forum/show...ompany-system)
          Giorgio Bravi
          Dolphin Software & Thinkware
          www.dolphin.it

          Comment


          • #6
            Cool I didnt know that.

            Comment

            Working...
            X