function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abhilash Mishra 13Abhilash Mishra 13 

sync salesforce Contacts to mysql database birectionally

I want to sync my salesforce contacts to mysql database. bidirectionally. what approach should i use from salesforce end. I am using Php.

Need help
Thanks
Nikhil Sharma 17Nikhil Sharma 17
You can use the PHP toolkit provided by the salesforce for it.
Here you will get all the sample code for PHP.
https://developer.salesforce.com/page/PHP_Toolkit

 
Daniel BallingerDaniel Ballinger
How quickly do you want updates in Salesforce to appear in PHP?
  1. There is the Streaming API (https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/), which can be used to receive notifications when Salesforce records are created, updated or deleted.
  2. If it is only a subset of records, you can use Outbound messages (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_om_outboundmessaging_setting_up.htm) to send notifications to a SOAP based web service.
  3. You can use a custom object in Salesforce to create a custom message queue. Then use a scheduled batch job to send the sync records out.
  4. You can use a scheduled weekly data export to extract all the data in a zip file.
  5. You can use the API getDeleted() (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_getdeleted.htm) and getUpdated() (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_getupdated.htm) methods to find records that have changed within a period. See also: Data Replication (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_guidelines_datareplication.htm)
Abhilash Mishra 13Abhilash Mishra 13
Hi deniel
Thanks For replying , I want updates less than a minute. in real time.
Abhilash Mishra 13Abhilash Mishra 13
Hi Nikhil,
Thanks for the answer.
but I want to configure it from salesforce end too. for other end i will use php tool kit.
Nikhil Sharma 17Nikhil Sharma 17
Hi Abhilash,
For this you have to create API in Salesforce or simply you can do this via PHP toolkit.
Simply get the records from salesforce and insert into your MYSQL via running a file periodically.
And insert the data into salesforce via PHP toolkit easily

// Insert the account record in salesforce
<?php

require_once ('connection.php');
$sObject = new stdClass();
$sObject->Name = 'Nikhil';
$sObject->Email__c = 'sharma.nikhil.f26@gmail.com'; 

$createResponse = $mySforceConnection->upsert('Email__c' , array($sObject),'Account');
echo "Creating new Account \r\n";
print_r($createResponse);




// Select the records from salesforce

$query = 'SELECT Id,Name from Account limit 5';
  $response = $mySforceConnection->query(($query));

  foreach ($response->records as $record) {
    print_r($record);
    print_r("<br>");
  }

 
Abhilash Mishra 13Abhilash Mishra 13
Thanks Nikhil, 
but i want control on salesforce end as I have said above. I am using PHP toolkit in the very sames ways as you coded. but this keep all the control on php end only.
Nikhil Sharma 17Nikhil Sharma 17
For that we have to implement the API in salesforce so that when we create, update or delete.The function or file in php is execute.