4 <?php include "_skipif.inc"; ?>
11 $c = new pq\Connection(PQ_DSN);
12 $c->exec("DROP TABLE IF EXISTS copy_test; CREATE TABLE copy_test (id serial, line text);");
14 $file = file(__FILE__);
16 $in = new pq\COPY($c, "copy_test (line)", pq\COPY::FROM_STDIN, "DELIMITER '\t'");
17 foreach ($file as $i => $line) {
18 $in->put(addcslashes($line, "\\\t"));
22 $out = new pq\COPY($c, "copy_test (line)", pq\COPY::TO_STDOUT, "DELIMITER '\t'");
23 while ($out->get($line)) {
24 $lines[] = stripcslashes($line);
27 var_dump($file == $lines);
29 if ($file != $lines) {
30 foreach (array_keys(array_diff($file, $lines)) as $idx) {
31 var_dump($idx, $file[$idx], $lines[$idx], "##############");
35 $c->exec("DROP TABLE copy_test");