Pdo\Sqlite::createAggregateRegisters an aggregating user-defined function for use in SQL statements 説明
public bool Pdo\Sqlite::createAggregate(
string $name ,callable $step ,callable $finalize ,int $numArgs = -1) This method is similar to Pdo\Sqlite::createFunction except that it registers functions that can be used to calculate a result aggregated across all the rows of a query. The key difference between this method and Pdo\Sqlite::createFunction is that two functions are required to manage the aggregate. ヒント
By using this method it is possible to override native SQL functions. パラメータ
戻り値
成功した場合に 例例1 Pdo\Sqlite::createAggregate example
In this example we will create a custom aggregate function named
In this example, we are creating an aggregating function,
named
After all the rows have been processed,
SQLite calls the
ヒント
It is NOT recommended for you to store a copy of the values in the context and then process them at the end, as you would cause SQLite to use a lot of memory to process the query - just think of how much memory you would need if a million rows were stored in memory, each containing a string 32 bytes in length. 参考
|