home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / .tmpsqlite_006.phpt < prev    next >
Encoding:
Text File  |  2004-03-24  |  957 b   |  53 lines

  1. --TEST--
  2. sqlite: regular 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.     array("one", "uno"),
  14.     array("two", "dos"),
  15.     array("three", "tres"),
  16.     );
  17.  
  18. sqlite_query("CREATE TABLE strings(a,b)", $db);
  19.  
  20. function implode_args()
  21. {
  22.     $args = func_get_args();
  23.     $sep = array_shift($args);
  24.     return implode($sep, $args);
  25. }
  26.  
  27. foreach ($data as $row) {
  28.     sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($row[0]) . "','" . sqlite_escape_string($row[1]) . "')", $db);
  29. }
  30.  
  31. sqlite_create_function($db, "implode", "implode_args");
  32.  
  33. $r = sqlite_query("SELECT implode('-', a, b) from strings", $db);
  34. while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
  35.     var_dump($row);
  36. }
  37. echo "DONE!\n";
  38. ?>
  39. --EXPECT--
  40. array(1) {
  41.   [0]=>
  42.   string(7) "one-uno"
  43. }
  44. array(1) {
  45.   [0]=>
  46.   string(7) "two-dos"
  47. }
  48. array(1) {
  49.   [0]=>
  50.   string(10) "three-tres"
  51. }
  52. DONE!
  53.