输出数组项

时间:2011-05-01 04:03:22

标签: php database arrays salesforce soql

我正在使用Salesforce.com Toolkit for PHP,我正在尝试输出我认为非常简单的东西。

这是工作示例代码

$query = "SELECT ID, Phone FROM Contact LIMIT 5";
$response = $mySforceConnection->query($query);

foreach ($response->records as $record) {
echo $record->ID." - ".$record->Phone;
}

我已经发现了查询,现在想要输出名称和数字。以下代码不起作用

$query = "SELECT owner.name, count(type) FROM Task LIMIT 5";
$response = $mySforceConnection->query($query);

foreach ($response->records as $record) {
echo $record->owner.name; //DOES NOT WORK
}

这是我在 print_r($ record);

时获得的内容
stdClass Object ( [Id] => [any] => Array ( [0] => First Last [1] => 2177 ) ) 

我只想输出“First Last - 2177”

1 个答案:

答案 0 :(得分:3)

foreach ($response->records as $record)
{
    echo implode(' - ', $record->any);
}