• tom_g
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hello. I am trying to access Salesforce throught the PHP API, and I am unable to retrieve any data from custom fields. I am using the enterprise wsdl, and a modified version of a code example I found online: [php code:]

function get_accounts($connection, $table, $id, $rows, $column)
{
  $query = "SELECT ";
  foreach($rows as $row)
  $query.=$row;
  $query.=" FROM ".$table." WHERE(".$column."='".$id."')";
  $queryOptions = new QueryOptions(10);
  $response = $connection->query($query, $queryOptions);
    // New code starts here
    if ($response->size == 1)
    {
        $accounts = $response->records;
    }
else 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(900);
            $response = $connection->queryMore($

response->queryLocator);
            $accounts = array_merge($accounts, $response->records);
 
        }
    }
 
  return $accounts;
} [end php code]
 
Then my syntax for extracting the data is: (since it should only get one record with the id) $accounts[0]->fieldname; or, if it is a custom field: $accounts->fieldname__c;.
Can someone please enlighten me?
  • December 30, 2010
  • Like
  • 0