Exemple #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;
 }
 public static function castLargeObject($lo, array $a, Stub $stub, $isNested)
 {
     $a['seek position'] = pg_lo_tell($lo);
     return $a;
 }
Exemple #3
0
 function stream_eof()
 {
     return pg_lo_tell($this->handle) >= $this->size;
 }
Exemple #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;
 }
Exemple #5
0
   dump($oid);
 } 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);
Exemple #6
0
$oid = pg_lo_create($db);
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";