test
[m6w6/ext-pq] / tests / lob001.phpt
1 --TEST--
2 large objects
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 $t = $c->startTransaction();
13
14 $lob = $t->createLOB();
15 $lob->write(file_get_contents(__FILE__));
16 var_dump($lob->tell());
17
18 $lob->seek(0, SEEK_SET);
19 $dat = $lob->read(filesize(__FILE__));
20 var_dump(hash("md5", $dat)==hash_file("md5", __FILE__));
21
22 $lob->truncate(5);
23
24 $lob = new pq\Lob($t, $lob->oid);
25 var_dump($lob->read(123));
26
27 $t->commit();
28 $t->unlinkLOB($lob->oid);
29
30 ?>
31 DONE
32 --EXPECTF--
33 Test
34 int(451)
35 bool(true)
36 string(5) "%c?php"
37 DONE
38