[PHP] Objects and Traversing
Hello Guys, Here is the object. How can I get access to the [Name] = access. People who help me with this can you please tell me what is the logic behind traversing the objects and how do you gather the values. Thanks. I am looking for an answer like this $queryResult-f-dsfsdf QueryResult Object ( [queryLocator] = [done] = 1 [records] = Array ( [0] = SObject Object ( [type] = Contact [fields] = [sobjects] = Array ( [0] = SObject Object ( [type] = Account [fields] = SimpleXMLElement Object ( [Name] = Access ) ) ) ) ) [size] = 1 )
Re: [PHP] Objects and Traversing
You should be able to access the Name field using this syntax: QueryResult-records[0]-sobjects[0]-fields-Name Reading from left-to-right: 1. accessing index 0 (zero) of the records array. 2. accessing index 0 (zero) of the objects array. 3. accessing the Name property of the fields SimpleXML element A more verbose approach would be: $fld = $queryObject-records;// get the records array $fld = $fld[0]; // get the first index of the array $fld = $fld-sobjects; // get the sobjects array $fld = $fld[0];// get the first index of the array $fld = $fld-fields; // get the fields SimpleXML element $fld = $fld-Name;// get the Name property Either way, you're walking left-to-right, top-to-bottom. ~Ted On 4-Jun-08, at 3:37 PM, VamVan wrote: Hello Guys, Here is the object. How can I get access to the [Name] = access. People who help me with this can you please tell me what is the logic behind traversing the objects and how do you gather the values. Thanks. I am looking for an answer like this $queryResult-f-dsfsdf QueryResult Object ( [queryLocator] = [done] = 1 [records] = Array ( [0] = SObject Object ( [type] = Contact [fields] = [sobjects] = Array ( [0] = SObject Object ( [type] = Account [fields] = SimpleXMLElement Object ( [Name] = Access ) ) ) ) ) [size] = 1 ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Objects and Traversing
VamVan wrote: Hello Guys, Here is the object. How can I get access to the [Name] = access. People who help me with this can you please tell me what is the logic behind traversing the objects and how do you gather the values. Thanks. I am looking for an answer like this $queryResult-f-dsfsdf QueryResult Object ( [queryLocator] = [done] = 1 [records] = Array ( [0] = SObject Object ( [type] = Contact [fields] = [sobjects] = Array ( [0] = SObject Object ( [type] = Account [fields] = SimpleXMLElement Object ( [Name] = Access ) ) ) ) ) [size] = 1 ) Simply this would give you name $QueryResult-records[0]-sobjects[0]-fields-Name -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php