summaryrefslogtreecommitdiff
path: root/ext/sqlite/tests/sqlite_004.phpt
blob: 4010066578cbfcc3d127641f09276b72cc59012c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--TEST--
sqlite: binary encoding
--INI--
sqlite.assoc_case=0
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded("sqlite")) print "skip"; ?>
--FILE--
<?php 
include "blankdb.inc";

$strings = array(
	"hello",
	"hello\x01o",
	"\x01hello there",
	"hello\x00there",
	""
);

sqlite_query("CREATE TABLE strings(a)", $db);

foreach ($strings as $str) {
	sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($str) . "')", $db);
}

$i = 0;
$r = sqlite_query("SELECT * from strings", $db);
while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
	if ($row[0] !== $strings[$i]) {
		echo "FAIL!\n";
		var_dump($row[0]);
		var_dump($strings[$i]);
	} else {
		echo "OK!\n";
	}
	$i++;
}

sqlite_close($db);

echo "DONE!\n";
?>
--EXPECT--
OK!
OK!
OK!
OK!
OK!
DONE!