now try something different
[m6w6/ext-pq] / tests / lob002.phpt
1 --TEST--
2 large object stream
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 fwrite($lob->stream, file_get_contents(__FILE__));
16 var_dump(ftell($lob->stream));
17
18 fseek($lob->stream, 0, SEEK_SET);
19 $dat = fread($lob->stream, filesize(__FILE__));
20 var_dump(hash("md5", $dat)==hash_file("md5", __FILE__));
21
22 ftruncate($lob->stream, 5);
23
24 $lob = new pq\Lob($t, $lob->oid);
25 var_dump(fread($lob->stream, 123));
26
27 $t->commit();
28 $t->unlinkLOB($lob->oid);
29
30 ?>
31 DONE
32 --EXPECTF--
33 Test
34 int(503)
35 bool(true)
36
37 Warning: ftruncate(): Can't truncate this stream! in %s on line %d
38 string(123) "<?php
39 echo "Test\n";
40
41 include "_setup.inc";
42
43 $c = new pq\Connection(PQ_DSN);
44 $t = $c->startTransaction();
45
46 $lob = $t->creat"
47 DONE
48