Vincent,
> currently I'm working with an Interbase 6.0 database and I
> want to insert
> some text (and eventually a picture) to a blob field. I've found the
> following php code:
>
> $bid = ibase_blob_create();
> ibase_blob_add($bid, "test");
> $comments_blob = ibase_blob_close($bid);
> $sql = "UPDATE tblcontent SET Metadata=? WHERE id=1";
> ibase_query($sql,$comments_blob);
> ibase_commit();
>
> When I try to retrieve this blobdata, I use the following code:
>
> $set = ibase_query("SELECT Metadata FROM tblcontent WHERE ID = 1");
> $row = ibase_fetch_object($set);
> $blob_id = ibase_blob_open($row->Metadata);
> $content = ibase_blob_get($blob_id);
> ibase_blob_close($blob_id);
> ibase_free_result($set);
>
> $content returns an empty string.
> I don't know if it goes wrong updating the data, or
> retrieving the data.
> Can anybody help me out here....
I've experienced flakiness using blobs with php. I did get it to work,
however. When I insert my text, I do not use a blob. When I retrieved the
results, I would use all capital letters for the field name, and I made use
of the ibase_blob_info() function:
$blob_data = ibase_blob_info( $row->METADATA );
$blob_hndl = ibase_blob_open( $row->METADATA );
$content = ibase_blob_get( $blob_hndl, $blob_data[0] ));
ibase_blob_close( $blob_hndl);
Hope this has some hints,
Patrick May