From: Operating system: Windows XP PHP version: 5.3.10 Package: PDO related Bug Type: Bug Bug description:Error in aggreagate function in PDO or Sqlite3
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 bug report at https://bugs.php.net/bug.php?id=61661&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=61661&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=61661&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=61661&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=61661&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=61661&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=61661&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=61661&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=61661&r=needscript Try newer version: https://bugs.php.net/fix.php?id=61661&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=61661&r=support Expected behavior: https://bugs.php.net/fix.php?id=61661&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=61661&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=61661&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=61661&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=61661&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=61661&r=dst IIS Stability: https://bugs.php.net/fix.php?id=61661&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=61661&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=61661&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=61661&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=61661&r=mysqlcfg