pq\Transaction docs
[mdref/mdref-pq] / pq / Transaction / importLOB.md
1 # int pq\Transaction::importLOB(string $local_path[, int $oid = 0)
2
3 Import a local file into a *large object*.
4
5 ## Params:
6
7 * string $local_path
8 A path to a local file to import.
9 * Optional int $oid = 0
10 The target OID. A new *large object* will be created if empty.
11
12 ## Returns:
13
14 * int, the (new) OID of the *large object*.
15
16 ## Throws:
17
18 * pq\Exception\InvalidArgumentException
19 * pq\Exception\BadMethodCallException
20 * pq\Exception\RuntimeException
21
22 ## Example:
23
24 <?php
25
26 $connection = new pq\Connection;
27 $transaction = $connection->startTransaction();
28
29 $oid = $transaction->importLOB(__FILE__);
30 $lob = $transaction->openLOB($oid);
31
32 var_dump($lob);
33
34 ?>
35
36 Yields:
37
38 object(pq\LOB)#5 (3) {
39 ["transaction"]=> {
40 ...
41 }
42 ["oid"]=>
43 int(74492)
44 ["stream"]=>
45 resource(6) of type (stream)
46 }