Hi all,
I am a sugar rabbitt, so please excuse if this has been discussed in this forum before:
I'm currentl playing with a couple of PHP SOAP routines that read data from Sugar, do some computation externally and rewrite the data as a mass update to custom fields in Sugar. (i.e. compose an url from stored information and store the link in a custom field). The DB has about 1700 records.
So far, the code works fine with less than 70 records, then stops without notice or error. I've checked the result code of the "last" working set_entry call. I assume my problem could be related to a memory allocation or possibly a browser timeout issue, but didn't find any hints googeling around. Any help would be greatly appreciated.
Here a code example (composes a google maps link and updates the custom field map_c in Accounts)
$c = $soap->getrecordcount('Accounts');
$result=$soap->getAccounts("",$c," accounts.name asc");
if($result['result_count']>0){
foreach($result['entry_list'] as $record){
$array= $soap->nameValuePairToSimpleArray($record['name_value_list']);
$map = $soap->create_map_url(
$array['billing_address_postalcode'],
$array['billing_address_city'],
$array['billing_address_street']
);
$result = $soap->update_map('Accounts', $array['id'], $map);
}
}
-------
Functions:
function getAccounts($query='',$maxnum=0,$orderby=' accounts.name asc') {
$result = $this->proxy->get_entry_list(
$this->sess,
'Accounts',
$query,
$orderby,
0,
array(
'id',
'name',
'billing_address_name',
'billing_address_street',
'billing_address_postalcode',
'billing_address_city',
'billing_address_country',
'phone_office',
'phone_fax',
),
$maxnum,
false
);
return $result;
}
function nameValuePairToSimpleArray($array) {
$my_array=array();
while(list($name,$value)=each($array)){
$my_array[$value['name']]=$value['value'];
}
return $my_array;
}
function getrecordcount($module) {
$count = $this->proxy->get_entries_count($this->sess, $module,'','0');
return $count[result_count];
}
function create_map_url($zip, $city, $street) {
$search = urlencode($street)."+".$zip."+".urlencode($city);
$google_url = "http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&z=16&q=".$searc h;
return $google_url;
}
function update_map($module, $id, $map) {
$fields = array(
array(
'name' => 'id',
'value' => $id
),
array(
'name' => 'map_c',
'value' => $map
),
);
$result = $this->proxy->set_entry($this->sess, $module, $fields);
return $result;
}


LinkBack URL
About LinkBacks



Reply With Quote
Robert

Bookmarks