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