0

我想按城市显示所有潜在客户组,我正在使用 php 将 SalesForce 集成到我的应用程序中,并且我有查询结果。

对于简单的查询,它不难显示结果,但对于像这样的查询

“选择 Count('Firstname'), City from Lead Group By City”

我不确定如何显示数组。

这是代码。

     $response = $mySforceConnection->query($query);

 foreach ($response->records as $record) 
 {
    $object = get_object_vars($record);
    print_r($object);
    echo "<br />";
 }

结果是这样的:

Array ( [Id] => [any] => Array ( [expr0] => 4 [0] => ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 1 [0] => Atlanta, GA ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 8 [0] => Austin, TX ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 3 [0] => Baltimore, MD ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 3 [0] => Boston, MA ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 10 [0] => Central Jersey, NJ ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 17 [0] => Central VA ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 1 [0] => Chicago East, IL ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 11 [0] => Chicago West, IL ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 2 [0] => Cleveland, OH ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 5 [0] => Dallas, TX ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 3 [0] => Detroit, MI ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 2 [0] => Fitchburgh, MA ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 1 [0] => Fort Worth, TX ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 10 [0] => Hartford, CT ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 1 [0] => Houstan Cypress ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 6 [0] => Houston North, TX ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 2 [0] => Houston South, TX ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 2 [0] => Indiana, IN ) ) 
Array ( [Id] => [any] => Array ( [expr0] => 14 [0] => LA East, CA ) ) 
4

1 回答 1

0

正如您在此处看到的,您可以按照以下说明显示计数:

foreach($object[expr0] as $child) {
    echo $child . "\n";
}

要打印城市,您必须替换$object[expr0]$object[0]

于 2013-08-19T00:10:34.613 回答