1
0
mirror of https://github.com/danog/ext-pq.git synced 2024-12-12 09:29:37 +01:00
ext-pq/tests/copy001.phpt

44 lines
831 B
Plaintext
Raw Normal View History

2013-01-30 17:21:38 +01:00
--TEST--
copy
--SKIPIF--
<?php include "_skipif.inc"; ?>
--FILE--
<?php
echo "Test\n";
include "_setup.inc";
$c = new pq\Connection(PQ_DSN);
$c->exec("DROP TABLE IF EXISTS copy_test; CREATE TABLE copy_test (id serial, line text);");
$file = file(__FILE__);
$in = new pq\COPY($c, "copy_test (line)", pq\COPY::FROM_STDIN, "DELIMITER '\t'");
foreach ($file as $i => $line) {
$in->put(addcslashes($line, "\\\t"));
}
$in->end();
$out = new pq\COPY($c, "copy_test (line)", pq\COPY::TO_STDOUT, "DELIMITER '\t'");
while ($out->get($line)) {
$lines[] = stripcslashes($line);
}
var_dump($file == $lines);
if ($file != $lines) {
foreach (array_keys(array_diff($file, $lines)) as $idx) {
var_dump($idx, $file[$idx], $lines[$idx], "##############");
}
}
$c->exec("DROP TABLE copy_test");
?>
DONE
--EXPECT--
Test
bool(true)
DONE