API to detect the default database server set in ISPconfig panel

Discussion in 'Developers' Forum' started by Bhavana, Feb 25, 2020.

  1. Bhavana

    Bhavana New Member

    Hi,

    I am from Softaculous team, for a user having remote database server set as default, we make query to the ISPConfig database-> 'server' table and fetched the value of 'db_server' which was set to 1

    But the value of 'db_server' can be 1 for more than 1 server, can you please provide us with the API to fetch the default database server set by the user in ISPConfig OR is there any key in database from where we can fetch which is the default database set by the user so as to provide first preference to that database server while installing scripts.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    If the local server is listed as a database server, then I would use that one. If it is not a database server, then there is a field default_dbserver in the client details, but not sure if it's always set.
     
  3. Bhavana

    Bhavana New Member

    Hi,

    Can you please provide us with the way to detect which is the default database server set if the user have added two database servers. Since between the two database server added only one of them must be the default database server.

    I have checked the client table 'default_dbserver' in ispconfig database, however when I enabled both the database server from the System-> Server Services the 'default_dbserver' value is not affected, rather the db_server value for both server is set to 1 in the server table.

    For example, the user's server is example1.com and he have set example2.com as well as example1.com as the database server from System-> Server Services
    The user wants that the scripts must be installed on database server example2.com

    Is there any way to detect the default database server set since from the System-> Server Services the user can enable both the database server.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    If the user has tow database servers available, then there is no default database server. As mentioned in my first post, check if the website server id is identical to one of the database server id's, in this case, select that server where both id's match. Otherwise, take the first server if you can't provide a selector for the user in your app to chose the database server.
     

Share This Page