note 26257 deleted from function.pg-lo-open by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 09:04:43 +0000 |
| Subject: | note 26257 deleted from function.pg-lo-open by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196885@lists.php.net to get a copy of this message | ||
Note Submitter: riccardo_ridenti at hotmail dot com
----
//INSERT FILE INTO DB
$fp = fopen($filename,"r");
$buffer = fread($fp,filesize($filename));
fclose($fp);
pg_query ($conn, "begin");
$oid = pg_lo_create ($conn);
//echo "$oid\n";
$rs = pg_exec($conn,"insert into table(object) values($oid);");//object field type must
be "oid"
$handle = pg_lo_open ($conn, $oid, "w");
//echo "$handle\n";
pg_lo_write ($handle, $buffer);
pg_lo_close ($handle);
pg_query ($conn, "commit"); //OR END
pg_close();
//GET BUFFER(file) FROM DB
$rs = pg_exec($conn,"select object from objects where id = xxxxxx;");
$row = pg_fetch_row($rs,0);
pg_query ($conn, "begin");
$loid = pg_lo_open($conn,$row[0], "r");
pg_lo_read_all ($loid);
pg_lo_close ($loid);
pg_query ($conn, "commit"); //OR END
pg_close();