View Single Post
  #3  
Old 06-26-2007, 08:21 AM
mike mike is offline
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
increasing runtime of set_time_limit

Since I stated in an earlier post about the scripts that were not finishing, I did some small changes within the main function to increase the run time of the loop while retrieving data from Salesforce.com.

It has to do with increasing the time limit so the script will basically reset itself each time it retrieves 500 records. The built in function in php is:
Code:
set_time_limit(300);
Here is an entire, working, function that can be modified to download the opportunity table and then do with it what you wish:


PHP Code:
function get_accounts($connection)
{

  
$query "Select Id, AccountId, Name, Description, StageName, Amount, Probability, ExpectedRevenue, TotalOpportunityQuantity, CloseDate,
            Type, NextStep, LeadSource, IsClosed, IsWon, ForecastCategory, CampaignId, HasOpportunityLineItem, Pricebook2Id,
            OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp FROM Opportunity"
;
  
//Description,
  
$queryOptions = new QueryOptions(500);
  
$response $connection->query(($query), $queryOptions);

    
// New code starts here
    
if ($response->size 0)
    {
        
$accounts $response->records;


            
// Cycles through additional responses if the number of records
            // exceeds the batch size
        
while (!$response->done)
        {
            
set_time_limit(300);
            
$response $connection->queryMore($response->queryLocator);
            
$accounts array_merge($accounts$response->records);

        }
    }

  return 
$accounts;

With the array merge and returning the $accounts, you can then use that array to store the data into Oralce, MySQL, or even write it to a CSV file if that is what you wish
Reply With Quote