Announcement

Collapse
No announcement yet.

trying to connect to multiple database

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

  • trying to connect to multiple database

    Hey guys working on a new project, thankfully its not to complex and havent ran into any bugs at long last, well yet. Hope I havent jinxed myself there, anyway am trying to connect to multiple db and am having some trouble hoping somebody can provide a solution....

    using Form, ajax event, have a select menu when change to add data from another db into field.

    this is what I have so far...


    /**
    * Selecting a field from another table - db to select
    */
    $check_db = "conn_mysql_1";

    /**
    * Selecting a field from another table
    */
    $check_sql = "SELECT providerID, providerRef"
    . " FROM providers"
    . " WHERE providerID = '" . {propProvider} . "'";
    sc_lookup(rs, $check_sql, $check_db);

    if (isset({rs[0][0]})) // Row found
    {
    {propProviderRef} = {rs[0][1]};
    }
    else // No row found
    {
    {propProviderRef} = "Nothing";
    }

    its just throwing errors, from what I have gathered from other examples this should be possible, or am I mistaken???

    Any help would be aprechiated

  • #2
    as much as I am not surprised that there is no reply yet, I could really REALLY do with one
    Would make my day if I could actually complete a project with this darn tool :P

    Comment


    • #3
      Sorry Jamie, I can't answer this question as I never have used more connections in the same project.
      Albert Drent
      aducom software netherlands
      scriptcase partner, reseller, support and (turn-key) development
      www.scriptcase.eu / www.scriptcase.nl

      Comment


      • #4
        Cant you uses federated tables? That would keep you in one single connection.
        I havent tried it myself yet but apparent that is just a remote database link (as it is called in oracle).
        https://dev.mysql.com/doc/refman/5.0...rated-use.html

        Comment


        • #5
          Hi,
          there is no problem using multiple connections in a project.
          I think the quotation marks probably don't match, i didn't count though.
          Try it plain and simple:
          I suppose {propProvider} is an integer field. If not your have to use '{propProvider}'

          sc_lookup(rs,"SELECT providerID, providerRef FROM providers WHERE providerID = {propProvider}","conn_mysql_1");

          That should do it.

          jsb

          Comment


          • #6
            Be careful to use the automatic lookup to decode fields ... if you are using a database other than the one associated with the main form will have errors in compilation. A ticket was opened months ago but no solution so far...
            Giorgio Bravi
            Dolphin Software & Thinkware
            www.dolphin.it

            Comment


            • #7
              Hi JamieO,

              I resolve this problem using MySql database,

              I develop my project using ONLY two pre-defined connections, one for login and other for other applications (in develop environment)

              In production environment
              in my login form I choose the company number, ( 01 02 03 etc....) then I construct global variables as
              "db_NN.tb_" as [gl_tb] for tables where NN is the company number
              "db_NN.cs_" as [dl_cs] for querys
              "db_NN" as [gl_db] for code

              My tables are named as tb_clients, tb_items, etc....
              My querys are named as cs_clients, cs_items, etc...

              THEN in every scriptcase applications, in SQL tab I put by example the table tb_clients, the variable for replace table name [gl_tb] and table name part to replace "tb_"
              scriptcase replace the word "tb_clients" by "db_NN.tb_clients"

              this work in scriptcase applications

              ---------------------------------------
              BUT in php code you use the other global variable, by example

              select * from [gl_db].tb_clients (mysql execute as "select * from db_NN.tb_clients")

              update name in [gl_db].tb_clients where cli_id = 5

              -------------------
              with this feature you do not define any other connection, only must be create the physical databases in the server, its work !!

              Aquiles

              Comment


              • #8
                Originally posted by jsbinca View Post
                Hi,
                there is no problem using multiple connections in a project.
                I think the quotation marks probably don't match, i didn't count though.
                Try it plain and simple:
                I suppose {propProvider} is an integer field. If not your have to use '{propProvider}'

                sc_lookup(rs,"SELECT providerID, providerRef FROM providers WHERE providerID = {propProvider}","conn_mysql_1");

                That should do it.

                jsb

                Nice will give that a try

                To others thanks, but I have to use multiple DB, the platform I am working on will eventually manage the database for 10 different websites including one main site and DB which will contain relevant information to be shared between all sites and dbs.

                Will update the thread once and if I have it solved for others in the future
                thanks again!

                Comment


                • #9
                  sweet working a treat! thanks very much!!!!!!!!!!

                  Will finish my first platform nearly one year after purchase lol

                  Thanks again!

                  Comment


                  • #10
                    How do you make query with 2 different database and 2 different host ?

                    Comment


                    • #11
                      sorry saohong, am not sure I have all database on the same server, as I host all sites and database just with different domains which is how I am doing this. sorry I cant help much, I havent seen any options either to actualy connect to another server other than the one deployed on.
                      Would be a nice feature thou to have added, maybe a request to scriptcase to actually manage multiple db on different server, so being able to define the server IP alone should do the trick and I would imagine should be easier enough for them to apply.
                      No idea how long that would take thou, am still waiting on silly things to be added like jquery number/item sliders.....

                      Comment

                      Working...
                      X