note 97128 deleted from sqlite3.createaggregate by danbrown
| From: | danbrown@php.net | Date: | Fri, 02 Apr 2010 18:17:04 +0000 |
| Subject: | note 97128 deleted from sqlite3.createaggregate by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-167663@lists.php.net to get a copy of this message | ||
Note Submitter: dave at NOSPAM dot hearthconnection dot org
----
The documentation doesn't tell you what the format for the callbacks is. The functions should
look like this:
<?php
function step_function($context, $rowcount, $arg1, $arg2,...)
{
// process the arguments and change the context
// to store your current state; context can include
// any PHP type
return $context; // this is how you store the context
}
function final_function($context, $rowcount)
{
// optionally, do final processing on the context
return $result_of_function;
// note: OFTEN, the result of your function was
// computed by the step function and is already in
// context, so you would say return $context;
// but other times, say, in calculating the median,
// you have to process the context and produce
// an answer. Whatever you return from the final
// function becomes the result of the SQLite
// Aggregate.
}
?>
Note that the context is NOT a reference variable, as far as I can tell.