Skip to content
Advertisement

how to save binary type in postgresql

this is php code to save binary data (image,3dmodeling)

To store 3d modeling and textures, it was a DB created to manage them in the first place.

use c# system.byte [] datas;
<?php

$mdata= $_POST['mdata'];
$mmtex= $_POST['mtex'];

$mntex= $_POST['ntext'];
$conn=@pg_connect("host=localhost dbname=postgres user=postgres password=1234");

$query=  "INSERT INTO tbl_min_mdl VALUES
('001',$mdata,$mmtex,$mntex)";  

$result = pg_query($conn, $query);

echo "$mdata";
//echo "2";
?>

When sending and receiving a file, the file is not converted . It seems that I have a wrong understanding of bytea that this method is not working properly now, but I am not sure.

this is table

postgres=# select *from tbl_min_mdl;
 mdl_cd | mdl_data | mdl_mt | mdl_nt | mdl_dt | mdl_pos
--------+----------+--------+--------+--------+---------
(0)

md_data , mdl_mt , mdl_nt is bytea[] type

what is wrong???

Refer to this https://www.postgresql.org/docs/10/datatype-binary.html

Advertisement

Answer

byte[] is not bytea[] type bytea[] typte

but i don’t load bytea file

bytea file is not used escape and decording

 mdl_cd | mdl_data | mdl_mt | mdl_nt | mdl_dt
--------+----------+--------+--------+--------
 001    | x       | x     | x     |
 001    | x       | x     | x     |
 001    | x       | x     | x     |
 001    | x       | x     | x     |
 001    | x       | x     | x     |
 001    | x       | x     | x     |

it is no work

only load file x it was not decording

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement