2017-06-01 6 views
0

データベースがある示していますPOSTGRESQLbytea型の列に画像を挿入すると0バイト

データベースドライバ:PDO

私のクエリは次のとおりです。

INSERT INTO 
poi (
    "idPoiCategory", 
    name, 
    "shortName", 
    description, 
    url, 
    source, 
    "contactPostalCode", 
    "contactCity", 
    "contactAddress", 
    "contactPhone", 
    "contactPhone2", 
    "contactMail", 
    "mediaPhotoCopyright", 
    "mediaPhotoMain", 
    "mediaPhotoMiniature1", 
    "mediaPhotoMiniature2", 
    "mediaPhotoOriginalWidth", 
    "mediaPhotoOriginalHeight", 
    "mediaPhotoMiniatureWidth", 
    "mediaPhotoMiniatureHeight", 
    "mediaPhotoCropX", 
    "mediaPhotoCropY", 
    "mediaPhotoCropWidth", 
    "mediaPhotoCropHeight" 
) 
VALUES (
    :id_poi_category, 
    :name, 
    :short_name, 
    :description, 
    :url, 
    :source, 
    :postal_code, 
    :city, 
    :street_with_number, 
    :phone_number_1, 
    :phone_number_2, 
    :mailto, 
    :photos_copyright, 
    :photo_main, 
    :photo_miniature_1, 
    :photo_miniature_2, 
    :photo_original_width, 
    :photo_original_height, 
    :photo_miniature_width, 
    :photo_miniature_height, 
    :photo_crop_x, 
    :photo_crop_y, 
    :photo_crop_width, 
    :photo_crop_height 
) 
RETURNING "idPoi" 

私が使用して結合のparams(bytea型のもの)です:

$stmt->bindParam(':photo_main', $fields['photo_main'], PDO::PARAM_LOB); 
$stmt->bindParam(':photo_miniature_1', $fields['photo_miniature_1'], PDO::PARAM_LOB); 
$stmt->bindParam(':photo_miniature_2', $fields['photo_miniature_2'], PDO::PARAM_LOB); 

質問:画像がバイト列に挿入されないのはなぜですか?それらの (列)サイズは0バイトを示します。これらのイメージを挿入しようとしていますが、列のサイズはまだ0バイトです。私はバイナリデータを16進数に変換しようとしましたが、それをカラムに入れることはできませんでした。結果は同じで、0バイトでした。

答えて

0

問題が管理者にあります。それはあなたにも '0バイト'として列を報告します、そこにデータがあります。これを調べるには、SQLクエリf.ex:octet_length( "column_name_with_bytea")で関数octet_length()を使用します。 0より大きい値を報告する必要があります。

関連する問題