« pg_tty
pg_untrace »

pg_unescape_bytea

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

pg_unescape_bytea — bytea 型のバイナリをアンエスケープする

説明

function pg_unescape_bytea(string $string): string

pg_unescape_bytea() は、bytea 型のデータ文字列を アンエスケープし、エスケープしていない文字列、 場合によってはバイナリデータを返します。

注意:

bytea 型を SELECT した場合、PostgreSQL は '\' で 始まる 8 進数のバイト値(例: \032)を返します。これをユーザーが手動で コンバートすることを期待されています。

パラメータ

string

PHP のバイナリ文字列に変換される PostgreSQL の bytea データを含む string。

戻り値

アンエスケープされたデータを文字列で返します。

例

例1 pg_unescape_bytea() の例

<?php 
  // データベースに接続する
  $dbconn = pg_connect('dbname=foo');
  
  // bytea データを取得する
  $res = pg_query("SELECT data FROM gallery WHERE name='Pine trees'");  
  $raw = pg_fetch_result($res, 'data');
  
  // バイナリに変換し、ブラウザに送信する
  header('Content-type: image/jpeg');
  echo pg_unescape_bytea($raw);
?>

参考

関連キーワード:
bytea   バイナリ   unescape   アンエスケープ   PostgreSQL   エスケープ   escape   untrace   バイト   手動   コンバート   期待   データベース   接続   dbconn   connect   dbname   query   gallery   Pine   trees   fetch   ブラウザ   送信   header
関連する関数・ページ:
function.pg-escape-bytea   function.pg-escape-identifier   function.pg-escape-string   function.pg-escape-literal   ref.pgsql   book.pgsql