在salesforce.com上的以下代码示例中多次使用$this->_mySforceConnection
之类的构造:
<?php
// SOAP_CLIENT_BASEDIR - folder that contains the PHP Toolkit and your WSDL
// $USERNAME - variable that contains your Salesforce.com username (must be in the form of an email)
// $PASSWORD - variable that contains your Salesforce.com password
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);
$sObject = new stdClass();
$sObject->FirstName = 'George';
$sObject->LastName = 'Smith';
$sObject->Phone = '510-555-5555';
$sObject->BirthDate = '1927-01-25';
$sObject->Email = 'test@test.com';
$createResponse = $this->_mySforceConnection->create(array($sObject), 'Contact');
echo "Creating New Contact\r\n";
print_r($createResponse);
$sObject->FirstName = 'Bill';
$sObject->LastName = 'Clinton';
$upsertResponse = $this->_mySforceConnection->upsert('Email', array ($sObject), 'Contact');
echo "Upserting Contact (existing)\r\n";
print_r($upsertResponse);
$sObject->FirstName = 'John';
$sObject->LastName = 'Smith';
$sObject->Email = 'testNew@test.com';
echo "Upserting Contact (new)\n";
$upsertResponse = $this->_mySforceConnection->upsert('Email', array ($sObject), 'Contact');
print_r($upsertResponse);
} catch (Exception $e) {
echo $mySforceConnection->getLastRequest();
echo $e->faultstring;
}
?>
我看到$mySforceConnection
是一个对象,但是什么呢
$this->_mySforceConnection
是指?为什么$this->
会在对象外使用?它是如何工作的?我唯一的猜测就是他们在他们的对象中做了一件我以前从未听说过的奇怪事情。