You need to sign in to do that
Don't have an account?
Jim Anderson
Access RelationShip Query results
Can any one tell me how to access Contact.Name form my code below, you can see I'm echo out a few different ways but nothing seems to work:
$strSQL = "SELECT Id,AssetId,AccountId, Contact.FirstName, ";
$strSQL .= "CaseNumber,Subject,Status,CreatedDate,What_is_your_acronym__c,Which_product__c ";
$strSQL .= "FROM Case ORDER BY Id DESC LIMIT 2 ";
$Result = $mySforceConnection->query($strSQL);
if ($Result->size == 0) {
NoRecords(0);
}else{
$records = $Result->records;
foreach ($records as $record) {
$sObject = new SObject($record);
echo $sObject->fields->CaseNumber.":: ";
echo $sObject->fields->Contact->FirstName."<br>";
echo $sObject->fields->FirstName;
}
}
$strSQL .= "CaseNumber,Subject,Status,CreatedDate,What_is_your_acronym__c,Which_product__c ";
$strSQL .= "FROM Case ORDER BY Id DESC LIMIT 2 ";
$Result = $mySforceConnection->query($strSQL);
if ($Result->size == 0) {
NoRecords(0);
}else{
$records = $Result->records;
foreach ($records as $record) {
$sObject = new SObject($record);
echo $sObject->fields->CaseNumber.":: ";
echo $sObject->fields->Contact->FirstName."<br>";
echo $sObject->fields->FirstName;
}
}
Did you ever get a reply to your question from '07? I'm actually up the same creek right now. I'm basically stuck on how to refer to stuff that was requested through dot-syntax.
$query = 'SELECT Sales_Region__c, Sales_Area__c, Owner.Name, OwnerId, StageName, Amount FROM Opportunity WHERE IsWon = FALSE LIMIT 10';
$queryOptions = new QueryOptions(500);
$response = $connection->query(($query), $queryOptions);
$records = $response->records;
foreach ($records as $r)
$r = new SObject($r);
Then... $r->fields->Sales_Region__c ...
is an example of how to refer to the regular fields, but I can't figure out how to refer to the field "Owner.Name" in PHP
I can find in if I print out "$records" using "print_r" but I can't figure out how to refer to it once it's embedded in the SObject
$sObject->sobjects[0]->fields->FirstName worked for me. So for you try:
$r->sobjects[0]->fields->Name
Also in your example:
foreach ($records as $r)
$r = new SObject($r);