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

Поиск
Список
Период
Сортировка
Искать

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

От:
"Joe Conway (wwc)" <jconway@cox.net>
Дата:
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

FAQ