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
vladislavvladislav 

API returns result on localhost, but NOT on server ?!

Hello. I'm using the PHP ToolKit version 20.0. I'm just doing a simple query to SUM some fields and return the result. It works just fine when I connect from localhost, but as long as I upload my code to a remote host and execute it from there I get empty result for records... Here is my code:

 

$mySforceConnection = new SforcePartnerClient();
$mySforceConnection->createConnection('partner.wsdl.xml');
$mySforceConnection->login($USERNAME, $PASSWORD.$SECURITY_TOKEN);

$options = new QueryOptions(2000); $mySforceConnection->setQueryOptions($options); 

$query = "SELECT SUM(Financial_Savings__c) FROM Opportunity"; 

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

print_r($queryResult); 
exit;

 

And the result on localhost is:

 

QueryResult Object
(
    [queryLocator] => 
    [done] => 1
    [records] => Array
        (
            [0] => SObject Object
                (
                    [type] => AggregateResult
                    [fields] => stdClass Object
                        (
                            [expr0] => 1098.35
                        )

                )

        )

    [size] => 1
)

 

 And the result from the remote host, where I upload exactly the same file and run it from there:

 

QueryResult Object
(
    [queryLocator] => 
    [done] => 1
    [records] => Array
        (
            [0] => SObject Object
                (
                    [type] => AggregateResult
                    [fields] => stdClass Object
                        (
                        )

                )

        )

    [size] => 1
)

 You can see that the [fields] are empty !

Anybody can help me with this?

Thanks.

Matt BrineyMatt Briney

I am having the same problem.  Only when I also request a standard field in addition to the expr0 query the $response array returns the standard field but not the calcualted field.

 

I was wondering if you experienced the same issue?

vladislavvladislav

Yes, exactly! I was using the latest API version at that time, had all required extensions runnig on both localhost and remote host and it just won't work when I'm making the call from my remote server. So I ended up with NOT using agregate function and just I pull all the data I need and do the agregation and calculations by myself over the result using PHP ...

 

Quite stupid, I may say!