Doc #61661 [Ver->Csd]: SQLite3::createAggregate() callbacks: insufficient docs
| From: | cmb@php.net | Date: | Sat, 22 Sep 2018 10:41:07 +0000 |
| Subject: | Doc #61661 [Ver->Csd]: SQLite3::createAggregate() callbacks: insufficient docs | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-16010@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61661&edit=1
ID: 61661
Updated by: cmb@php.net
Reported by: xelloss at hotmail dot it
Summary: SQLite3::createAggregate() callbacks: insufficient
docs
-Status: Verified
+Status: Closed
Type: Documentation Problem
Package: SQLite related
Operating System: Windows XP
PHP Version: 5.3.10
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Previous Comments:
------------------------------------------------------------------------
[2018-09-22 10:40:42] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=345679
Log: Fix #61661: SQLite3::createAggregate() callbacks: insufficient docs
------------------------------------------------------------------------
[2018-09-22 10:22:33] cmb@php.net
This works as expected, but certainly the documentation of
SQLite3::createAggregate() and friends needs improvement regarding
the callbacks.
------------------------------------------------------------------------
[2012-04-07 20:25:19] xelloss at hotmail dot it
Description:
------------
---
From manual page: http://www.php.net/sqlite3.createaggregate#refsect1-sqlite3.createaggregate-description
---
I'm trying to use the aggregate function of sqlite3class and also in pdo.
I try to use the same code from SQLiteDatabase
(http://php.net/manual/en/function.sqlite-create-aggregate.php), changed for work with these two
function.
But the variable context is always empty.
See code below for example.
I can declare a global variable context, but it will be used always (everytime it start with last
value and if I use the aggregate function more than 1 time in a query the variable became shared)
Test script:
---------------
$data = array(
'one',
'two',
'three',
'four',
'five',
'six',
'seven',
'eight',
'nine',
'ten',
);
$dbhandle = new SQLite3(':memory:');
$dbhandle->exec("CREATE TABLE strings(a)");
foreach ($data as $str) {
$str = sqlite_escape_string($str);
$dbhandle->exec("INSERT INTO strings VALUES ('$str')");
}
function max_len_step(&$context, $string)
{
echo "-" . $context;
echo "<br>";
if (strlen($string) > $context) {
$context = strlen($string);
}
}
function max_len_finalize(&$context)
{
return $context;
}
$dbhandle->createAggregate('max_len', 'max_len_step',
'max_len_finalize');
$rs = $dbhandle->query('SELECT max_len(a) from strings');
Expected result:
----------------
-
-3
-3
-5
-5
-5
-5
-5
-5
-5
Actual result:
--------------
-
-
-
-
-
-
-
-
-
-
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61661&edit=1