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
bstrippbstripp 

(Beginner) When I querry a related record what format does it come in?

So I have two custom objects, class and location with the relation class --> location.

 

When I make my call I use the following:

 

Select c.Location__r.Name, c.Course_Name__c From Class__c c

 

It works fine, but I am noticing that the relationship seems to be returning an array.  I'm not familiar enough with Eclipse to verify this, but since you have to click on the relationship to see the data that was my guess.

 

I have two questions on the process:

(1) Should I tell my PHP script to expect an array?  Or since I know it's going to be one value in all cases, can I just call it a varriable of the correct type?

 

(2) Is there any way to do a more traditional join?

 

Thanks all!

MJBuschMJBusch

1.

What you get seems unfortuantly to be denpending on your version of PHP (Currently looking into that).

But assuming you run 5.3.0 or higher and uses the partner WSDL:

 

If You make a qurey like this:

  SELECT
                        Monkey__c,
                        Banana__c,
                        Account.zoo__c
                FROM
                        Contract
                WHERE
                        Banana__c != null

 

 You result will be a QueryResult Object which look likes this

(
    [queryLocator] =>
    [done] => 1
    [records] => Array
        (
            [0] => SObject Object
                (
                    [type] => Contract
                    [fields] => stdClass Object
                        (
                            [Monkey__c] => Gorilla
                            [Banana__c] => Dole
                            [Account] => SObject Object
                                (
                                    [type] => Account
                                    [fields] => stdClass Object
                                        (
                                            [zoo__c] => co-15
                                        )

                                )

                        )

                )

            [1] => SObject Object
                (
                    [type] => Contract
                    [fields] => stdClass Object
                        (
                            [Monkey__c] =>Bafoon

                            [Banana__c] => Dole

                            [Account] => SObject Object
                                (
                                    [type] => Account
                                    [fields] => stdClass Object
                                        (
                                            [zoo__c] => co-101
                                        )

                                )

                        )

                )

    )

    [size] => 2

)

 

 

 

2.

For how to make SOQL statements my best advice is to look at http://www.salesforce.com/us/developer/docs/api/ > Reference > Core Calls > query