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