Subject Re: [firebird-php] Binary data
Author masotti
Hi,

On 27/02/2012 11:05, Lester Caine wrote:
> But returning to CHAR ... If I configure that field as CHARACTER SET
> OCTET I
> should be able to simply handle the hex2bin output? I'm just about to
> dive into
> tidying that particular bodge up as currently I'm using CHAR(16) and just
> storing the hex :)


Storing the value as a parameter should work, i.e. something like

ibase_query ("UPDATE TABLE SET FIELD = ?", hex2bin
("65f0e300a96578616d706c6520"));

Indeed FB 2.5 has hex literal support, i.e. (from RN)
select x'deadbeef' from rdb$database
select 0x10, cast('0x0F0000000' as bigint) from rdb$database;

so instead using hex2bin()... (AFAIU it's not portable to other DBs)
I didn't check, but I would expect that IBExpert should show correct
binary data with connection CHARSET NONE.

Selecting data, that I see that as a tricky part.
UUID_TO_CHAR() shouldn't help, as, AFAIU, you've not UUIDs to store.
So you'll have a binary data in a PHP var, and only unpack() perhaps
should help.

Ciao.
Mimmo.