Annotation of embedaddon/php/ext/sqlite/tests/sqlite_closures_001.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: sqlite: aggregate functions with closures
                      3: --INI--
                      4: sqlite.assoc_case=0
                      5: --SKIPIF--
                      6: <?php # vim:ft=php
                      7: if (!extension_loaded("sqlite")) print "skip"; ?>
                      8: --FILE--
                      9: <?php 
                     10: include "blankdb.inc";
                     11: 
                     12: $data = array(
                     13:        "one",
                     14:        "two",
                     15:        "three"
                     16:        );
                     17: 
                     18: sqlite_query("CREATE TABLE strings(a)", $db);
                     19: 
                     20: foreach ($data as $str) {
                     21:        sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($str) . "')", $db);
                     22: }
                     23: 
                     24: function cat_step(&$context, $string)
                     25: {
                     26:        $context .= $string;
                     27: }
                     28: 
                     29: function cat_fin(&$context)
                     30: {
                     31:        return $context;
                     32: }
                     33: 
                     34: sqlite_create_aggregate($db, "cat", function (&$context, $string) {
                     35:        $context .= $string;
                     36: }, function (&$context) {
                     37:        return $context;
                     38: });
                     39: 
                     40: $r = sqlite_query("SELECT cat(a) from strings", $db);
                     41: while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
                     42:        var_dump($row);
                     43: }
                     44: 
                     45: sqlite_close($db);
                     46: 
                     47: echo "DONE!\n";
                     48: ?>
                     49: --EXPECT--
                     50: array(1) {
                     51:   [0]=>
                     52:   string(11) "onetwothree"
                     53: }
                     54: DONE!

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>