~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to ext/sqlite/tests/sqlite_006.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
38
sqlite_close($db);
 
39
 
 
40
echo "DONE!\n";
 
41
?>
 
42
--EXPECT--
 
43
array(1) {
 
44
  [0]=>
 
45
  string(7) "one-uno"
 
46
}
 
47
array(1) {
 
48
  [0]=>
 
49
  string(7) "two-dos"
 
50
}
 
51
array(1) {
 
52
  [0]=>
 
53
  string(10) "three-tres"
 
54
}
 
55
DONE!