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