function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Web DepartmentWeb Department 

No "fields" attribute (to access the results) in Partner WSDL query response

I'm following this ( tutorial and trying to performing a simple query with my SforcePartnerClient object...
$query = "SELECT Id, FirstName FROM Contact"
$response = $mySforceConnection->query($query);
foreach ($response->records as $record)
	echo $record->fields->FirstName;
...but the above code doesn't output anything. Looking at it in the debugger shows that "fields" is null. It DOES, however, seem to have the proper SOAP results inside "$record->any".

Any idea what might be wrong?
Pat PattersonPat Patterson
To save memory with large result sets, the raw response is not fully parsed in the query() call. You need to write your loop like this:

$queryResult = new QueryResult($response);
for ($queryResult->rewind(); $queryResult->pointer < $queryResult->size; $queryResult->next()) {

That sample code is out of date. I'll go update it right now.