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
SmileonlSmileonl 

COUNT_DISTINCT not working

Hi all, I have a question why such a query works

SELECT COUNT() FROM OpportunityHistory WHERE  OpportunityId IN (SELECT Id FROM Opportunity WHERE CreatedDate = THIS_WEEK)

 and such an error

SELECT COUNT_DISTINCT(OpportunityId) FROM OpportunityHistory WHERE  OpportunityId IN (SELECT Id FROM Opportunity WHERE CreatedDate = THIS_WEEK)

 

ERROR:

 

 Invalid argument supplied for foreach() in /var/www/dev.local/system/libraries/salesforce/SforcePartnerClient.php on line 344
sebcossebcos

Hi,

I am not sure if this can help but are you using the latest Force.com PHP Toolkit:

http://wiki.developerforce.com/index.php/Force.com_Toolkit_for_PHP ?

COUNT_DISTINCT is only available for API version 18.0 and later.

Just a wild guess why this might not work for you.

SmileonlSmileonl

Hi, i use the last version to PHP toolkit 20.

LakshmanLakshman

I do have same problem with SUM() aggregate function. The result type is AggregateResult but don't know how to handle this in Php. Any help appreciated.

 

Regards

Lakshman

colingcoling

Hi,

 

You may want to take a look at the thread I started in December about the support (or lack of it) in php toolkit 20.

 

See http://boards.developerforce.com/t5/Perl-PHP-Python-Ruby-Development/Problem-getting-counts-with-GROUP-BY-using-php-and-partner-wsdl/m-p/224829

 

I also saw another thread about a possible toolkit version 21. It's anybody's guess as to whether it will support count()/group by.

 

Colin G