You need to sign in to do that
Don't have an account?
JJUPO
First Step PHP Toolkit -- Query
Hello everyone,
I'm learning how to use the PHP toolkit, and I nedd some help. I want to query the Account Name field, so I do this
<?php require_once ('sforce-php/soapclient/SforcePartnerClient.php'); try { $mySforceConnection = new SforcePartnerClient(); $mySoapClient = $mySforceConnection->createConnection("sforce-php/samples/partner.wsdl.xml"); $mylogin = $mySforceConnection->login(LOGIN,PASSWORD+TOKEN); $userResult = $mylogin->userInfo; $query = 'SELECT Id,Name from Account limit 5'; $response = $mySforceConnection->query(($query)); $sObject = new stdClass(); foreach ($response->records as $record) { print_r($sObject->Name); print_r("<br>"); } } catch (Exception $e) { echo $e->faultstring; } ?>
But I get: Notice: Undefined property: stdClass::$Name
Any advice?
Thanks in advance
Best regards
JJUPO
The SQL you are using isn't compaitble with SalesForce. That's a MySQL query. You have to use Oracle SQL (SOQL) (yes, it's different).
The LIMIT 5 is not valid. You need to look at the response object for success or failure:
$mQR = $mSforceConnection -> query( $mSQL );
if ( $mQR === false || $mQR -> done == false )
{
return false;
}
if ( count( $mQR -> records ) < 1 )
{
// No record(s) returned.
return null;
}