downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

pg_untrace> <pg_tty
[edit] Last updated: Fri, 24 Feb 2012

view this page in

pg_unescape_bytea

(PHP 4 >= 4.3.0, PHP 5)

pg_unescape_bytea Faz escape binário para o tipo bytea

Descrição

string pg_unescape_bytea ( string $data )

pg_unescape_bytea() faz uma versão binária da string do tipo bytea. Retorna a string em binário(binary).

Nota:

Quando você faz SELECT bytea type, PostgreSQL returna um valor em octal prefixado por \ (por exemplo: \032). Usuários devem fazer a transformação em binário por si próprios.

Esta função exige PostgreSQL 7.2 ou superior. Com PostgreSQL 7.2.0 e 7.2.1, o tipo de dados bytea deve ser criado quando você habilita o suporte a multi-byte. Por exemplo, INSERT INTO tabela_teste (imagem) VALUES ('$imagem_escaped'::bytea); PostgreSQL 7.2.2 ou superior não precisa de coerção (cast). A exceção é quando a codificação de caracteres do cliente e do backend não combinam, então pode haver erro de fluxo de multi-byte. O usuário deve fazer a coerção (cast) para bytea para evitar este erro.

Veja também pg_escape_bytea() e pg_escape_string()



pg_untrace> <pg_tty
[edit] Last updated: Fri, 24 Feb 2012
 
add a note add a note User Contributed Notes pg_unescape_bytea
muralito at montevideo dot com dot uy 17-Mar-2011 05:10
The workaround is to configure a property in the postgres database for the user, to make postgres behave as the old default.

ALTER USER username SET bytea_output = 'escape';

(or using the pgadmin interface)
liviu dot mirea at gmail dot com 15-Oct-2010 10:06
PostgreSQL 9.0 introduced "hex" as the new default format for encoding binary data. Because "pg_unescape_bytea" only works with the old "escape" format, you need to do pg_query('SET bytea_output = "escape";'); before executing your select queries.

More details can be found here: http://www.postgresql.org/docs/9.0/static/datatype-binary.html
tiagopastorello at gmail dot com 30-Jun-2008 12:31
<?php
$conexao
= pg_connect("host=localhost dbname=name user=postgres password=123456") or die('Sorry =( : ' . pg_last_error());

$cod= $_GET['cod'];

$sql = "SELECT * FROM table WHERE cod_field = '$cod'";
$quer = pg_query($conexao, $sql);

$reg = pg_fetch_object($query);

print
pg_unescape_bytea($reg -> field_bytea);

?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites