Jump to:

10931 Posts in 2614 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » Form connect to secondary mssql database

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 438 Views
  • morganastreal
    Avatar
    Community Member
    4 Posts

    Form connect to secondary mssql database Link to this post

    I found a couple of old post that asked about having a Silverstripe connect to a second database however there didn't seem to be a solution.

    What my client requires is for the the forms to submit to a sales database that is running MSSQL on a different server.
    The Silverstripe website I have developed uses MySQL as it is more stable.

    I have created the forms using the UserDefinedForm module and have added a call into the submission to trigger a custom php file that is meant to connect and insert the data into the external MSSQL database.
    The form then continues as normal with the email responses and submission the the Silverstripe database.

    I was looking at doing something like the following and to keep it constant with Silverstripe database declare everything inside and array first.

       function submitToCRM( $form ) {
          $crmConfig = array(
             'type' => 'MSSQLDatabase',
             'server' => 'server',
             'username' => 'username',
             'password' => 'password',
             'database' => 'database',
             'secondDB' => 'true'
          );
          
          $crm = mssql_connect( $crmConfig['server'], $crmConfig['username'], $crmConfig['password'], $crmConfig['secondDB'] )
             or die ('cannot connect to CRM');
          
          mssql_select_db ( $crmConfig['database'], $crm )
             or die ( 'Can not select database' );
             
          /* check if details already entered */
          
          /* insert details */
          
          /* close connection */
          $crm = mssql_close();
       }

    however this is obviously wrong and I not familar enough with php to workout the syntex for the connect.

    Help would be much appreciated.

    Kate

  • morganastreal
    Avatar
    Community Member
    4 Posts

    Re: Form connect to secondary mssql database Link to this post

    Issue was in regards to my host company "Quadra Hosting" which does not allow connect to from php to external SQL database when running in a Unix server account.

    438 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.