Database name in webERP

Recently we implemented a weberp based solution for one of our esteemed clients. The development server was hosted on apthost and hence we had to manage database from the apthost cpanel. As we are all aware of the fact that cpanel will pre-append the user name of the shared user to the database that you create from it, we wanted weberp to adjust database name according to that (or for that matter, what ever may be the reason for you to chose a different database name. In case you are interested in looking at other solutions, do checkout our post on open source erp solutions. Weberp supports multiple companies in one installation and hence there can be multiple databases. The trick here is that the name of the database must match the name of the sub-directory in the companies folder. We have been getting a lot of queries on if we can change the association of sub-directories with the database name in the webERP. Unfortunately as of weberp version 3.11, There is still no getting around the fact that the database name and the sub directory under the company directory should still be identical. In case, you are using webERP thro its web-services, then you would need to make another change for the end points to work correctly. You will need to change the variable $DatabaseName to refer to the name of your database. The variable is defined in apiapi_php.php
$DatabaseName='weberpdemo';
Change this to the name of your company and you will be all set to go. Though this is not a proper method and proper implementation should be introduced to specify the name of the company from the API calls, but this works for now. Good Luck with your webERP implementation !!
  • http://www.facebook.com/infinitedimensions Nick Hargreaves

    no success

    • http://twitter.com/enbake Enbake Consulting

      Hi Nick whats the problem that you are facing with the fix ?

  • http://www.facebook.com/infinitedimensions Nick Hargreaves

    no success

    • Anonymous

      Hi Nick whats the problem that you are facing with the fix ?

  • http://twitter.com/enbake Enbake Consulting

    Hi Nick whats the problem that you are facing with the fix ?

  • Anonymous

    Hi Nick whats the problem that you are facing with the fix ?

  • Na

    I have found solution to it… replace below function in apiapi_php.php
    Now pass database name in API call. e.g. in api_currencies.php add databasename parameter in function GetCurrencyList and pass it from functions used in api_xml-rpc.php

    function db($user, $password, $database = ”) {
    if (!isset($_SESSION[‘AccessLevel’]) OR
    $_SESSION[‘AccessLevel’] == ”) {
    // Login to default database = old clients.
    if ($user != ” && $password != ”) {
    global $api_DatabaseName;
    if($database != ”)
    $api_DatabaseName = $database;
    $rc = LoginAPI ($api_DatabaseName, $user, $password);
    if ($rc[0] == UL_OK ) {
    return $_SESSION[‘db’];
    }
    }
    return NoAuthorisation;
    } else {
    return $_SESSION[‘db’];
    }
    }

    • http://twitter.com/enbake Enbake Consulting

      ah yes .. this is a possibility if you have flexibility enough to change the core code. For us, this was not the possibility because our clients would replace the weberp code folder as it is whenever a new version was released and hence causing issues .. :)
      Good solution nevertheless.

      • Na

        yes.. in your case, it would be a problem… one might have to wait till such functionality available in core… I do not know how can suggest community to incorporate such small modification.. may be you can help…

        • http://twitter.com/enbake Enbake Consulting

          For sure, We have a couple of open source API to contribute and discuss with Tim(founder of weberp). We can put forward this feature request as well !!

  • Na

    I have found solution to it… replace below function in apiapi_php.php
    Now pass database name in API call. e.g. in api_currencies.php add databasename parameter in function GetCurrencyList and pass it from functions used in api_xml-rpc.php

    function db($user, $password, $database = ”) {
    if (!isset($_SESSION[‘AccessLevel’]) OR
    $_SESSION[‘AccessLevel’] == ”) {
    // Login to default database = old clients.
    if ($user != ” && $password != ”) {
    global $api_DatabaseName;
    if($database != ”)
    $api_DatabaseName = $database;
    $rc = LoginAPI ($api_DatabaseName, $user, $password);
    if ($rc[0] == UL_OK ) {
    return $_SESSION[‘db’];
    }
    }
    return NoAuthorisation;
    } else {
    return $_SESSION[‘db’];
    }
    }

    • Anonymous

      ah yes .. this is a possibility if you have flexibility enough to change the core code. For us, this was not the possibility because our clients would replace the weberp code folder as it is whenever a new version was released and hence causing issues .. :)
      Good solution nevertheless.

      • Na

        yes.. in your case, it would be a problem… one might have to wait till such functionality available in core… I do not know how can suggest community to incorporate such small modification.. may be you can help…

        • Anonymous

          For sure, We have a couple of open source API to contribute and discuss with Tim(founder of weberp). We can put forward this feature request as well !!