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
ClaiborneClaiborne 

Query Problem - sforce Toolkit

When I perform a query with lots of fields, the result object is coming back with the "any" field being an array instead of a string. I have built a work-around by modifying the ConvertAny function to build a string by contatenating the array elements into a single string.
 
Is there something causing this problem?
Tran ManTran Man
David, can you post your query and then echo one of the objects you get back?
ClaiborneClaiborne
For some reason, the weird behavior is no longer occurring. I can not reproduce what was happening on Monday.
 
I will keep a lookout for it, but it seems to have solved itself for now.
mharleymharley
I am having a similar problem to the original poster.

When I make the following query
   "Select Id, BillingState, BillingCity, BillingStreet from Account"
the results for the last 3 query fields are concatinated into a string
and returned in the [any] field.

An example of an object returned:

stdClass Object
(
    [type] => Account
    [Id] => Array
    (
        [0] => 0015000000EmggxAAB
        [1] => 0015000000EmggxAAB
    )
    [any] => ONOttawa77 Metcalfe St.
)

Also is the Id supposed to be returned as a 2 element array?

Thanks
Mike

Message Edited by mharley on 07-04-2006 03:34 PM

ClaiborneClaiborne

The results you are getting are correct.

What you want to do is convert the returned result to an SObject,

Typically, the code looks like this:

Code:

$query = "Select Id, BillingState, BillingCity, BillingStreet ".
   " FROM Account
response = $client->query($query, $queryOptions);
if (response->size >0) {
   foreach($response->records as $r) {
      $r = new SObject($r)
      code here to work on $r
      As an SObject, $r->type = type of field
                     $r->id = the id of the record
                     $r->fields = array of items from the query
                     $r->fields->BillingState 
                     $r->fields->BillingCity, etc.

   }
}


 
Hope this helps.

mharleymharley
Thanks, that worked fine!