Bug->Doc #61661 [Opn->Ver]: SQLite3::createAggregate() callbacks: insufficient docs
| From: | cmb@php.net | Date: | Sat, 22 Sep 2018 10:22:33 +0000 |
| Subject: | Bug->Doc #61661 [Opn->Ver]: SQLite3::createAggregate() callbacks: insufficient docs | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-16009@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: Error in aggreagate function in PDO or Sqlite3
+Summary: SQLite3::createAggregate() callbacks: insufficient
docs
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
-Package: PDO SQLite
+Package: SQLite related
Operating System: Windows XP
PHP Version: 5.3.10
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This works as expected, but certainly the documentation of
SQLite3::createAggregate() and friends needs improvement regarding
the callbacks.
Previous Comments:
------------------------------------------------------------------------
[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