xref: /PHP-5.3/ext/sqlite/tests/sqlite_004.phpt (revision b842917d)
1--TEST--
2sqlite: binary encoding
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$strings = array(
13	"hello",
14	"hello\x01o",
15	"\x01hello there",
16	"hello\x00there",
17	""
18);
19
20sqlite_query("CREATE TABLE strings(a)", $db);
21
22foreach ($strings as $str) {
23	sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($str) . "')", $db);
24}
25
26$i = 0;
27$r = sqlite_query("SELECT * from strings", $db);
28while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
29	if ($row[0] !== $strings[$i]) {
30		echo "FAIL!\n";
31		var_dump($row[0]);
32		var_dump($strings[$i]);
33	} else {
34		echo "OK!\n";
35	}
36	$i++;
37}
38
39sqlite_close($db);
40
41echo "DONE!\n";
42?>
43--EXPECT--
44OK!
45OK!
46OK!
47OK!
48OK!
49DONE!
50