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

« back to all changes in this revision

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