Example #1
0
 function length()
 {
     if (!($e = $this->_firstUse())) {
         return $e;
     }
     pg_lo_seek($this->blob, 0, PGSQL_SEEK_END);
     $len = pg_lo_tell($this->blob);
     pg_lo_seek($this->blob, 0, PGSQL_SEEK_SET);
     if (!$len) {
         return $this->_setDbError('get length of');
     }
     return $len;
 }
Example #2
0
 function stream_seek($offset, $whence = SEEK_SET)
 {
     return pg_lo_seek($this->handle, $offset, $whence);
 }
Example #3
0
 function stream_seek($offset, $whence = PGSQL_SEEK_SET)
 {
     return pg_lo_seek($this->loh, $offset, $whence);
 }
Example #4
0
 public function length()
 {
     if (!($e = $this->_firstUse())) {
         return $e;
     }
     @pg_lo_seek($this->_blob, 0, PGSQL_SEEK_END);
     $len = @pg_lo_tell($this->_blob);
     @pg_lo_seek($this->_blob, 0, PGSQL_SEEK_SET);
     if (!$len) {
         return $this->_raiseError('get length of');
     }
     return $len;
 }
Example #5
0
 } elseif( substr($req,0,11) == 'blob_delete' ) {
   list($oid) = sscanf( $req, 'blob_delete %u' );
   $oid = pg_lo_unlink($oid) or pgerr('lo_unlink failed');
 } elseif( substr($req,0,10) == 'blob_write' ) {
   list($oid) = sscanf( $req, 'blob_write %s ' );
   $bin = substr($req,12+strlen($oid));
   $obj = pg_lo_open($oid,'w') or pgerr( 'lo_open failed' );
   $res = pg_lo_write($obj,$bin) or pgerr( 'lo_write failed' );
   pg_lo_close($obj);
   dump($res);
 } elseif( substr($req,0,9) == 'blob_read' ) {
   list($oid) = sscanf( $req, 'blob_read %u' );
   $obj = pg_lo_open($oid,'r') or pgerr( 'lo_open failed' );
   pg_lo_seek($obj,0,PGSQL_SEEK_END);
   $len = pg_lo_tell($obj);
   pg_lo_seek($obj,0,PGSQL_SEEK_SET);
   $res = pg_lo_read($obj,$len) or pgerr( 'lo_read failed' );
   pg_lo_close($obj);
   dump($res);
 } else {
   $result = pg_query($req) or pgerr("error at request: $req");
   if( pg_result_status($result) == PGSQL_COMMAND_OK ) {
     dump( 0 );
     dump( pg_affected_rows($result) );
     dump( pg_last_oid($result) );
     pg_free_result($result);
   } elseif( pg_result_status($result) == PGSQL_EMPTY_QUERY ) {
     dump( 0 );
     dump( 0 );
     pg_free_result($result);
   } elseif( pg_result_status($result) == PGSQL_TUPLES_OK ) {
Example #6
0
if (!$oid) {
    echo "pg_lo_create() error\n";
}
$handle = pg_lo_open($db, $oid, "w");
if (!$handle) {
    echo "pg_lo_open() error\n";
}
pg_lo_write($handle, "large object data\n");
pg_lo_close($handle);
pg_exec($db, "commit");
echo "open/read/tell/seek/close LO\n";
pg_exec($db, "begin");
$handle = pg_lo_open($db, $oid, "w");
pg_lo_read($handle, 100);
pg_lo_tell($handle);
pg_lo_seek($handle, 2);
pg_lo_close($handle);
pg_exec($db, "commit");
echo "open/read_all/close LO\n";
pg_exec($db, "begin");
$handle = pg_lo_open($db, $oid, "w");
pg_lo_read_all($handle);
if (pg_last_error()) {
    echo "pg_lo_read_all() error\n" . pg_last_error();
}
pg_lo_close($handle);
pg_exec($db, "commit");
echo "unlink LO\n";
pg_exec($db, "begin");
pg_lo_unlink($db, $oid) or print "pg_lo_unlink() error 1\n";
pg_exec($db, "commit");