You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
801 B

  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. $data = array(
  12. "one",
  13. "two",
  14. "three"
  15. );
  16. sqlite_query("CREATE TABLE strings(a)", $db);
  17. foreach ($data as $str) {
  18. sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($str) . "')", $db);
  19. }
  20. function cat_step(&$context, $string)
  21. {
  22. $context .= $string;
  23. }
  24. function cat_fin(&$context)
  25. {
  26. return $context;
  27. }
  28. sqlite_create_aggregate($db, "cat", "cat_step", "cat_fin");
  29. $r = sqlite_query("SELECT cat(a) from strings", $db);
  30. while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
  31. var_dump($row);
  32. }
  33. sqlite_close($db);
  34. echo "DONE!\n";
  35. ?>
  36. --EXPECT--
  37. array(1) {
  38. [0]=>
  39. string(11) "onetwothree"
  40. }
  41. DONE!