Can't find any examples of using aggregate functions with fRecordSet::build. Can someone please give me some examples? :)
Thanks in advance.
Are you referring to this ancient thing? http://www.php.net/manual/en/function.aggregate.php ?
no, how can i use avg, min, max on the recordset.
I don't see how using these on the RecordSet itself makes much sense. It is possible to "filter" recordsets if you're looking for particular records based on a criteria. What I'm suspecting you're trying to do is use these on particular values on records in the recordset.
You can call a particular method on the records in a recordset using the fRecordSet::call() method. This allows you to essentially get the return of those calls as an array with one simple line. So for example if you had a bunch of files with a 'download_count' column, you might do something like the following:
$average_download_count = avg($record_set->call('getDownloadCount'));
I have never tried this, but I don't see why it wouldn't work.
errr... avg() apparently isn't a function, haha, are you referring to SQL here? min() and max() are functions, and the above would work with them:
$highest_download_count = max($record_set->call('getDownloadCount'));
If you are referring to SQL, it'd probably be helpful to see what you're trying to do in regards to the SQL. Generally speaking a recordset is going to reflect a selection of a number of records and all their columns. Since Flourish uses the schema information to determine the nature of available columns, etc, you can't arbitrarily select a function value and create an "abstract" record so to speak (at least not as far as I know).
You could use a simple fDatabase query to get a Result and then fetchScalar() on it if you are trying to get these values in the SQL itself.
Yeah, atm I am using simple query and fetchScalar(). I am just curious how to use flourishs aggregate functions, there is an example for count in the docs:
I just need few more use cases for avg, min and max ...
Thanks for your kind help.