function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tammyCMCtammyCMC 

Fatal error: Class 'QueryResult' not found

Hi
i know it's something basic but i don't understand :(

i get this error
Fatal error: Class 'QueryResult' not found in C:\scripts\index.php on line 12

from this code:


require_once("c:/php/sforce/soapclient/SforceEnterpriseClient.php");
require_once ('c:/php/sforce/soapclient/SforceHeaderOptions.php');
require_once ('c:/php/sforce/userAuth.php');
$conn= new SforceEnterpriseClient();
$conn->createconnection("enterprise.wsdl.xml");
$mylogin=$conn->login($myusername,$mypassword);
$query="select firstname,lastname,email from contact where username__c='abcdefgh'";

$response=$conn->query($query);
$queryresult = new QueryResult($response);
foreach ($queryresult->records as $result) {

$Name= $result->fields->firstname;
print_r("
name is ");
print_r ($Name);
}

thanks for any help
tammy
Best Answer chosen by Admin (Salesforce Developers) 
NBlasgenNBlasgen

First off, IMHO, I hate the entire concept of the Enterprise WDSL.  So limited.  You should be useing the Partner file because it doesn't need any updates performed if you change objects in your org.

 

So there is no object type called QueryResults, so just strip out that line and everything about your code should work.

 

echo "Found {$response->size} results in this query\n";

foreach ($response->records as $result) {

  print_r($result);

}

 

Now it's possible you might need to type cast the results to get them to properly form themselves, but if I remeber correctly the Enterprise WDSL will do this for you.  Try the above code, and then you can figure out what the proper names of the fields are.

All Answers

NBlasgenNBlasgen

First off, IMHO, I hate the entire concept of the Enterprise WDSL.  So limited.  You should be useing the Partner file because it doesn't need any updates performed if you change objects in your org.

 

So there is no object type called QueryResults, so just strip out that line and everything about your code should work.

 

echo "Found {$response->size} results in this query\n";

foreach ($response->records as $result) {

  print_r($result);

}

 

Now it's possible you might need to type cast the results to get them to properly form themselves, but if I remeber correctly the Enterprise WDSL will do this for you.  Try the above code, and then you can figure out what the proper names of the fields are.

This was selected as the best answer
tammyCMCtammyCMC

thanks much!

once i used the partner file and got the case right on the field names :) it worked!!