Go Back   Mike Simonds > Salesforce > Salesforce PHP Tutorials

This is a discussion on Salesforce PHP 2 within the Salesforce PHP Tutorials forums, part of the Salesforce category; Sometimes organizations deal with large record sets and updating your instance of

Reply
 
LinkBack Thread Tools Rate Thread
  #1  
Old 05-18-2007, 09:39 AM
Administrator
 
Join Date: May 2007
Posts: 288
Send a message via AIM to mike Send a message via MSN to mike Send a message via Yahoo to mike Send a message via Skype™ to mike
Salesforce PHP 2

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:21 AM.



Powered by vBulletin


SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.

1 2 3 4 5