Query Result: Where does “any” come from?

I created a simple custom object in salesforce.

There are 3 Extra fields: id, email, name (API Names: id__c, email__c, name__c)

I dumped 100 rows of random Mockup data into that object (some fields are empty)

There are no cennection, relationships, filters and other things. Just a plain table.

I created a query, which looks like… (There are no line breaks within the code, it should just give a better overview)

string(164) "SELECT 
                Id, OwnerId, IsDeleted, Name, CreatedDate, 
                CreatedById, LastModifiedDate, LastModifiedById, 
                SystemModstamp, id__c, name__c, email__c 

Now… it seems i got something wrong, because I didn’t expecte the result to look like the following dump:

object(QueryResult)#22 (6) {
  array(100) {
    object(stdClass)#23 (3) {
      string(19) "MartinTestObject__c"
      array(2) {
        string(18) "a0426000001Kjd3AAC"
        string(18) "a0426000001Kjd3AAC"
      string(502) "00524000000TsJlAAKfalse12015-10-07T15:49:09.000Z00524000000TsJlAAK2015-10-07T15:49:09.000Z00524000000TsJlAAK2015-10-07T15:49:09.000Z1Antonio Gordonagordon0@desdev.cn"
  .... .... .... //100 times the same contents

Especially the “any” key got me there. Why is it just all data concatenated?

I expected it, to look a bit more like a SQL result… How to accomplish that?

Code for request is more or less a copy of the samples…

$this->connection = new SforcePartnerClient();
$this->client = $this->connection->createConnection("/path/to/salesforce.wsdl");
$this->login = $this->connection->login($this->login, decrypt($this->password).(($this->securityKey)?decrypt($this->securityKey):""));

$query = "SELECT ".implode(", ",$this->tableInfo["columns"])." FROM ".$this->tableInfo["table"];
debug::debugD($query); //dump of Query

$options = new QueryOptions(200);

$response = $this->connection->query($query);

$queryResult = new QueryResult($response);
!$done = false;
debug::Debugd($queryResult); //Dump of result


You need to wrap the response in a QueryResult object which’ll do the work of decoding the any array for you. e.g.

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

See the PHP Toolkit samples for more info

Source : Link , Question Author : Mruf , Answer Author : superfell

Leave a Comment