|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61661 Error in aggreagate function in PDO or Sqlite3
Submitted: 2012-04-07 20:25 UTC Modified: 2014-01-01 12:38 UTC
From: xelloss at hotmail dot it Assigned:
Status: Open Package: PDO SQLite
PHP Version: 5.3.10 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: xelloss at hotmail dot it
New email:
PHP Version: OS:


 [2012-04-07 20:25 UTC] xelloss at hotmail dot it
From manual page:
I'm trying to use the aggregate function of sqlite3class and also in pdo.
I try to use the same code from SQLiteDatabase (, 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(

$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:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-01-01 12:38 UTC]
-Package: PDO related +Package: PDO SQLite
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC