php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #61661 SQLite3::createAggregate() callbacks: insufficient docs
Submitted: 2012-04-07 20:25 UTC Modified: 2018-09-22 10:41 UTC
From: xelloss at hotmail dot it Assigned: cmb (profile)
Status: Closed Package: SQLite related
PHP Version: 5.3.10 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
15 + 13 = ?
Subscribe to this entry?

 
 [2012-04-07 20:25 UTC] 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:
--------------
-
-
-
-
-
-
-
-
-
-

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-01-01 12:38 UTC] felipe@php.net
-Package: PDO related +Package: PDO SQLite
 [2018-09-22 10:22 UTC] cmb@php.net
-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 -Assigned To: +Assigned To: cmb
 [2018-09-22 10:22 UTC] cmb@php.net
This works as expected, but certainly the documentation of
SQLite3::createAggregate() and friends needs improvement regarding
the callbacks.
 [2018-09-22 10:40 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=345679
Log: Fix #61661: SQLite3::createAggregate() callbacks: insufficient docs
 [2018-09-22 10:41 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2018-09-22 10:41 UTC] cmb@php.net
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.
 [2020-02-07 06:05 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=599a6e381eac09aabbd08ce7317d6ef8c71f19f4
Log: Fix #61661: SQLite3::createAggregate() callbacks: insufficient docs
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC