Annotation of embedaddon/php/ext/sqlite/tests/sqlite_005.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: sqlite: aggregate functions
! 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", "cat_step", "cat_fin");
! 35:
! 36: $r = sqlite_query("SELECT cat(a) from strings", $db);
! 37: while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
! 38: var_dump($row);
! 39: }
! 40:
! 41: sqlite_close($db);
! 42:
! 43: echo "DONE!\n";
! 44: ?>
! 45: --EXPECT--
! 46: array(1) {
! 47: [0]=>
! 48: string(11) "onetwothree"
! 49: }
! 50: DONE!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>