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