php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58627 Improve support for binary large objects
Submitted: 2009-04-09 13:39 UTC Modified: 2018-08-27 09:37 UTC
From: kolar dot radim at gmail dot com Assigned: vnkbabu (profile)
Status: Closed Package: ibm_db2 (PECL)
PHP Version: 5.2.4 OS: Ubuntu 8.04 LTS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kolar dot radim at gmail dot com
New email:
PHP Version: OS:

 

 [2009-04-09 13:39 UTC] kolar dot radim at gmail dot com
Description:
------------
For my next application i need better interface to large objects. I need following functions:

int db2_lob_length(resource $stmt  , int $colnum  );
  return size of blob object in bytes.

We probably need some way to get large object handle such as
lobj db2_lob_open ( resource $stmt  , int $colnum )
int  db2_lob_close ( lobj $obj )

to implement functionality i need:
int db2_lob_write ( lobj $obj  , string $data  );
  write data to large object
string db2_lob_read  ( lobj $obj  , int $length  )
  read data from lob
int db2_lob_seek  ( lobj $obj, int $offset);
  change offset in lob for reading and writing


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-13 04:16 UTC] abhargav at in dot ibm dot com
Hi,

Thanks for using our driver and you suggestions. 

Can you provide us a sample, which is using all these functions/APIs (the way you are expecting it)? Also provide the information about the contain of the tables and the expected output of that sample. 

I will look into it and will try to add these APIs.

Regards,
Ambrish Bhargava
 [2010-08-05 14:18 UTC] kolar dot radim at gmail dot com
Here is testcase for my proposed new functions

Database setup;

drop table b1;
commit;
create table b1 (id integer not null, data blob not null);
insert into b1 (id,data) values(10,blob('--binary-blob-here--'));
commit;

$conn = db2_connect('SAMPLE);
$stmt = db2_prepare($conn,'select data from b1 where id=10');
db2_execute($stmt);
db2_fetch_row($stmt);

// first function is easy get length of blob
// but entire blob should not travel over wire to db2 client because
// i plan to about 700 MB big blobs

db2_lob_length($stmt,1);
    returns 20;

// get lob object handle
$lobj = db2_lob_open($stmt,1);
    returns large object handle
	
db2_lob_read($lobj,2);
     returns '--';

db2_lob_read($lobj,2);
	 returns 'bi';

db2_lob_seek($lobj, 0);
	  returns true; // returns boolean value - sucess
	  
db2_lob_read($lobj,2);
	  returns '--';
	  
db2_lob_write($lobj,'un');
	  returns true; // boolean - success
	  
db2_lob_read($lobj,2);
	  returns 'na'

db2_lob_seek($lobj,2);
	  returns true;
	  
db2_lob_read($lobj,2);
	  returns 'un';
	  
db2_lob_close($lobj);
	  returns true; // success
 [2011-07-05 03:33 UTC] hsn at sendmail dot cz
i just looked at package documentation and there is already 
function db2_lob_read. I propose to make functions, 
compatible with current lob API.

1.
boolean db2_lob_write ( resource $stmt , int $colnum , 
string  $data )
writes data into large object

2.
int db2_lob_seek ( resource $stmt , int $colnum , int   
$offset )
changes offset in LOB object for reading/writing. returns 
new offset

3.
function for truncating lob object
int db2_lob_set_size ( resource $stmt , int $colnum , int   
$size )
sets LOB size to $size. if lob is larger it will get 
truncated. returns new offset

4.
returns size of lob object
int db2_lob_get_size($stmt,int $colnum);
 [2018-08-27 09:37 UTC] vnkbabu@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: vnkbabu
 [2018-08-27 09:37 UTC] vnkbabu@php.net
As this issue is very old, Closing this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC