Retrieving blobs from sybase

From: Date: Tue, 05 Sep 2000 16:25:07 +0000
Subject: Retrieving blobs from sybase
Groups: php.db 
Request: Send a blank email to php-db+get-2621@lists.php.net to get a copy of this message
I am storing imagefiles as blobs in a sybase database and when I retrieve them I only get the first 32768 hex nibbles back. The table is defined as: create table blob ( blob_id t_id identity, blobtype_id t_id null , title varchar(80) null , body image null , constraint pk_blob primary key (blob_id) ) I store the blob using the following code: echo "<H3>Updating.. filetype $userfile_type name $userfile_name size $userfile_size</H3>"; printf ("Bytes tempfile %d<br>\n",filesize($userfile)); $fp=fopen($userfile,'r'); $blob=bin2hex(fread($fp,filesize($userfile))); printf ("Bytes hexcode %d<br>\n",strlen($blob)); fclose($fp); $mimetypeid=getblobtype($userfile_type,$userfile_name); $qid=sybase_query(" INSERT INTO blob(blobtype_id,title,body) VALUES ($mimetypeid,'$blobtitle',0x".$blob.")"); if (!$qid){ echo "Database error<BR>\n"; } $newblobid=getsybid(); $qid=sybase_query(" INSERT INTO blobforobject(blob_id,object_id,linkname) VALUES ($newblobid,$objectid,'$blobtitle')"); And when I retrieve them using: function do_showblobobject($blobobjectid){ global $conid; $qid=sybase_query(" SELECT blobtype.mimetype,blob.body FROM blob,blobtype WHERE blob.blob_id=$blobobjectid AND blob.blobtype_id=blobtype.blobtype_id",$conid); if ($qid){ list($blobtype_mimetype,$blob_body)=sybase_fetch_row($qid); // header("Content-Type: $blobtype_mimetype"); $bloblen=strlen($blob_body); echo "Len = $bloblen<br>body= $blob_body\n"; // echo pack("H".$bloblen,$blob_body); } } Then the length is maximum 32768 bytes, whatever I try. The length of the objects in the database is big enough : 1> select datalength(body) from blob 2> go ----------- 44723 219743 8784 23994 (4 rows affected) Any hints on what I am missing ? Koos van den Hout -- Koos van den Hout, PGP keyid RSA/1024 0xCA845CB5 via keyservers koos@kzdoos.xs4all.nl or DSS/1024 0xF0D7C263 -?) Fax +31-30-2817051 Visit my site about books with reviews /\\ http://idefix.net/~koos/ http://www.virtualbookcase.com/ _\_V

« previous php.db (#2621) next »