mirror of
https://github.com/php/php-src.git
synced 2026-03-26 09:12:14 +01:00
Add a test-case for that process. When encoding binary data, we mark the string with \x01 as its first character. When returning data via sqlite_fetch_array(), if the first character is \x01, then we decode the encoding. This behaviour can be turned off by the optional last parameter to sqlite_fetch_array(), for compatibility with databases created with other applications.
45 lines
711 B
PHP
45 lines
711 B
PHP
--TEST--
|
|
sqlite: binary encoding
|
|
--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++;
|
|
}
|
|
echo "DONE!\n";
|
|
?>
|
|
--EXPECT--
|
|
OK!
|
|
OK!
|
|
OK!
|
|
OK!
|
|
OK!
|
|
DONE!
|