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'");
19 $c === $in->connection,
20 "copy_test (line)" === $in->expression,
21 pq\COPY::FROM_STDIN === $in->direction,
22 "DELIMITER '\t'" === $in->options
25 foreach ($file as $i => $line) {
26 $in->put(addcslashes($line, "\\\t"));
30 $out = new pq\COPY($c, "copy_test (line)", pq\COPY::TO_STDOUT, "DELIMITER '\t'");
33 $c === $out->connection,
34 "copy_test (line)" === $out->expression,
35 pq\COPY::TO_STDOUT === $out->direction,
36 "DELIMITER '\t'" === $out->options
39 while ($out->get($line)) {
40 $lines[] = stripcslashes($line);
43 var_dump($file == $lines);
45 if ($file != $lines) {
46 foreach (array_keys(array_diff($file, $lines)) as $idx) {
47 var_dump($idx, $file[$idx], $lines[$idx], "##############");
51 $c->exec("DROP TABLE copy_test");