Re: OK got it, BYTEA, PHP, Storing Images

Поиск
Список
Период
Сортировка
От Joe Conway (wwc)
Тема Re: OK got it, BYTEA, PHP, Storing Images
Дата
Msg-id 3C48924E.2040905@cox.net
обсуждение исходный текст
Список pgsql-general
Thomas T. Thai wrote:

> if you look at the decode function, i had to put those 'search' strings in
> single quotes. i honestly don't know why it works with 5 backslashes
> there. maybe someone can figure this out.
>

> to encode for bytea:
>
> function encodeByteA($binData) {
>   // \000 = 00 = NULL,         \012 = 10 = VerticalTab,
>   // \047 = 39 = Single Quote, \134 = 92 = backslash
>
>   $search = array(chr(0), chr(10), chr(39), chr(92));
>   $replace = array("\\\\000", "\\\\012", "\\\\047", "\\\\134");
>   $binData = str_replace($search, $replace, $binData);
>   return $binData;
> }


Thanks!
BTW, later testing showed that escaping chr(10) was really unnecessary.

>
> to decode for bytea:
>
> function decodeByteA($binData) {

Why the decode function -- I thought stripcslashes() worked OK?

Joe


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

Предыдущее
От: Andrew Sullivan
Дата:
Сообщение: Re: large file limitation
Следующее
От: "Cornelia Boenigk"
Дата:
Сообщение: Re: Need book on PHP and PostgreSQL