salesforce将对象记录到字符串

时间:2016-08-09 13:25:18

标签: php casting salesforce

我正在尝试解析这个对象的saleforce返回,但是没有运气,因为它不是String而我不知道如何使它成为String。

查询的当前代码:

<?php
    define("SOAP_CLIENT_BASEDIR", "../../soapclient");
    require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
    require_once ('../userAuth.php');
    try {
      $mySforceConnection = new SforceEnterpriseClient();
      $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
      $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
      $query = 'SELECT DataIncluded__c from GMC_Contract__c limit 5';
      $response = $mySforceConnection->query(($query));
      foreach ($response->records as $record) {
        print_r($record);
        print_r("<br>");
      }
    } catch (Exception $e) {
      echo $e->faultstring;
    }
    ?>

这里打印/运行时返回如下内容:

stdClass Object ( [Id] => [DataIncluded__c] => 8 )
stdClass Object ( [Id] => [DataIncluded__c] => 11 )
stdClass Object ( [Id] => [DataIncluded__c] => 5 ) 

假设3条记录。我想只是得到数字,所以它打印8然后11然后5。

但是子字符串不起作用,我尝试更改为字符串也没有用。关于我如何做到这一点的任何建议?

1 个答案:

答案 0 :(得分:1)

试试这段代码

echo $record->DataIncluded__c

而不是

print_r($record)

因为$ record是一个对象而Id是一个数组。