transform event handlers to zvals;
[m6w6/ext-pq] / tests / copy001.phpt
1 --TEST--
2 copy
3 --SKIPIF--
4 <?php include "_skipif.inc"; ?>
5 --FILE--
6 <?php
7 echo "Test\n";
8
9 include "_setup.inc";
10
11 $c = new pq\Connection(PQ_DSN);
12 $c->exec("DROP TABLE IF EXISTS copy_test; CREATE TABLE copy_test (id serial, line text);");
13
14 $file = file(__FILE__);
15
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"));
19 }
20 $in->end();
21
22 $out = new pq\COPY($c, "copy_test (line)", pq\COPY::TO_STDOUT, "DELIMITER '\t'");
23 while ($out->get($line)) {
24 $lines[] = stripcslashes($line);
25 }
26
27 var_dump($file == $lines);
28
29 if ($file != $lines) {
30 foreach (array_keys(array_diff($file, $lines)) as $idx) {
31 var_dump($idx, $file[$idx], $lines[$idx], "##############");
32 }
33 }
34
35 $c->exec("DROP TABLE copy_test");
36
37 ?>
38 DONE
39 --EXPECT--
40 Test
41 bool(true)
42 DONE
43