Sometimes organizations deal with large record sets and updating your instance of Salesforce can cause a timeout. This happened in my organization when I tried to update the product2 object, which has over 130,000 records. No matter what you may use to do your updates (e.g the dataloaded, a desktop application, or a php script) on large oobjects/tables, the run time will be large. The product2 script that I wrote initially was timing out because of the query that was being ran against our local Oracle DB. To me, timeouts can be dangerous becuase it can stop in the middle of the update script, which can cause data loss or a stopping point that can be hard to track down if the script times out.
So what can you do to stop this when working with large data sets? I tried a few different solutions to this issue, here is the best that I found. Usually when you connect to Salesforce.com using PHP, you are extracting data out of some sort of local database (e.g Oracle or MySql). Instead of adding the login at the beginning of your insert or update script, add it
within the loop, prior to the upload.
PHP Code:
while ($record_count == $number_records)
{
$sql = "SELECT *
FROM your table";
//Move your Login information prior to sending your array to the
//function that will acutally perform the insert, update, or upsert
//This will insure that you always login each time you loop
//through the query that retrieves your data
// Salesforce Login information
$wsdl = './includes/soapclient/partner.wsdl.xml';
$userName = "myemail@email.com";
$password = "salesforce password";
// Process of logging on and getting a salesforce.com session
$client = new SforcePartnerClient();
$client->createConnection($wsdl);
$loginResult = $client->login($userName, $password);
$success = your_insert($client, $sObjects);
}
What does this do you may ask? This causes the script to login to salesforce each time your script runs through the loop. if you treid to process 130,000 records updates at one single login, your script would likely fail. If you LIMIT your query to 200 records per insert, update, or upsert and login each time you process these records, you will likely not have any issues with some sort of session time out