[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-db
Subject:    RE: [PHP-DB] Interbase BLOB problem
From:       "David Russell" <DavidR () BarloworldOptimus ! com>
Date:       2002-10-30 8:53:41
[Download RAW message or body]


Hi Peter,

Thanks for this. I have been waiting for the PHP Manuals to include
documentation on the interbase BLOB functions. I need to find a real
connection and download it <grin>

Actually my problem was that I have 2 machines - Windows (development
and testing) and Linux (Server). The site was initially made in an all
Linux environment. Now I am maintaining and expanding on my Windows box.

The problem was with the fopen(<file> "r") which on Windows needs to be
fopen(<file>, "rb") for binary files.

It is all working now.

Thanks again to all.

David Russell
IT Support Manager
Barloworld Optimus (Pty) Ltd
Tel: +2711 444-7250 
Fax: +2711 444-7256
e-mail: DavidR@BarloworldOptimus.com
web: www.BarloworldOptimus.com

-----Original Message-----
From: Peter Beckman [mailto:beckman@purplecow.com] 
Sent: 29 October 2002 05:47 PM
To: David Russell
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Interbase BLOB problem


Your SQL query doesn't need that semicolon at the end of the query --
lose it.

I never used ibase, so here's what I found from the PHP Manual page for
ibase_query:

Using BLOB

Insert BLOB:

/* create blob */
$blob_id = ibase_blob_create();

/* fill blob */
ibase_blob_add($blob_id, $var_datablob);

/* close new blob */
$blob_id_str = ibase_blob_close($blob_id);

/* insert into table */
ibase_query("INSERT INTO BLOB_TABLE (ID, BLOB) VALUES (1,
?)",$blob_id_str);

Open BLOB:

/* query */
$set = ibase_query("SELECT BLOB FROM BLOB_TABLE WHERE ID = 1");

/* fetche a row */
$row = ibase_fetch_object($set);

/* open BLOB for read */
$blob_id = ibase_blob_open($row->BLOB);

/* get BLOB data */
$stringBLOB = ibase_blob_get($blob_id);

/* print BLOB */
echo $stringBLOB;

/* close new blob */
ibase_blob_close($blob_id);

/* free result */
ibase_free_result($set);

Peter

On Tue, 29 Oct 2002, David Russell wrote:

> Hi all,
>
> I have a file I need to insert into a blob in a interbase table. Code 
> as
> follows:
>
>     $filehandle = fopen($file, "r");
>     $blob_id = ibase_blob_import($filehandle);
>     $qry = "INSERT INTO BPFATTACHMENTS ";
>     $qry = $qry . "(BPFATTACHMENTNO, BPF, ATTACHMENTTYPE, FILENAME, 
> FILESIZE, ATTACHMENT)";
>     $qry = $qry . "VALUES";
>     $qry = $qry . "($bpfAttNo, $BPFNo, $AttachmentType, '$file_name', 
> $file_size, ?);";
>     $res = ibase_query($qry, $blob_id);
>
> I have a ibase_pconnect prior to this.
>
> The problem is that is only adds a tiny part of the file (ie 5k of the

> 200k file) What should I be looking for?
>
> Thanks
>
> David Russell
> IT Support Manager
> Barloworld Optimus (Pty) Ltd
> Tel: +2711 444-7250
> Fax: +2711 444-7256
> e-mail: DavidR@BarloworldOptimus.com
> web: www.BarloworldOptimus.com
>

------------------------------------------------------------------------
---
Peter Beckman            Systems Engineer, Fairfax Cable Access
Corporation
beckman@purplecow.com
http://www.purplecow.com/
------------------------------------------------------------------------
---


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


["smime.p7s" (application/x-pkcs7-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic