Re: bytea

Поиск
Список
Период
Сортировка
От Jonathan Bartlett
Тема Re: bytea
Дата
Msg-id Pine.SUN.4.58.0405110927380.21862@eskimo.com
обсуждение исходный текст
Ответ на bytea  (Dennis Gearon <gearond@fireserve.net>)
Ответы Re: bytea  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Re: bytea  (Dennis Gearon <gearond@fireserve.net>)
Список pgsql-general
> Also, if I wanted to put a *.pdf file in a bytea column, what functions
> do I use to escape any characters in it?

What programming language are you using?

In Perl, you do something like:

$sth->bind_param(1, $file_data, DBI::SQL_BINARY); #DBI::SQL_BINARY is
deprecated, but it works

In php you do:

$file_data = pg_escape_bytea($file_data);

$db->query("insert into blah(blahh) values ('${file_data}'::bytea);

To retrieve the info in Perl, it's just a regular fetchrow()

my ($file_data) = $sth->fetchrow();

In php, you have to run stripcslashes() on the data.

list($file_data) = $query->fetchrow();
$file_data = stripcslashes($file_data);

Jon


>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

В списке pgsql-general по дате отправления:

Предыдущее
От: "Thomas LeBlanc"
Дата:
Сообщение: Re: How to move data from 1 database to another?
Следующее
От: Nick Barr
Дата:
Сообщение: Re: How to move data from 1 database to another?