thales.pereira Posted June 29, 2011 Share Posted June 29, 2011 Hi, im trying to store and retrieve some small files ( 3k min 15k max ) into a table, but until now only figure out how to store I dont know if this is the best way, but i think it works ( i dont know if it stores the file right into the table, but i can see the table growing ) <?php #bd config include 'config.php'; #bd call include 'opendb.php'; $name='node.ndf'; $fp = fopen($name, 'rb'); $content = fread($fp, filesize($name)); $content = pg_escape_string($content); $sql=("insert into storage values ('$content'::bytea)"); pg_query($sql) or die(pg_last_error()); ?> But how do i extract those files from the table? PS: the postgresqlField to store is bytea. Regards, Thales Pereira Link to comment https://forums.phpfreaks.com/topic/240698-storing-and-retrieving-files-into-postgresql-or-mysql/ Share on other sites More sharing options...
fugix Posted June 29, 2011 Share Posted June 29, 2011 how many fields do you have in your db table, just the one? Link to comment https://forums.phpfreaks.com/topic/240698-storing-and-retrieving-files-into-postgresql-or-mysql/#findComment-1236281 Share on other sites More sharing options...
thales.pereira Posted June 29, 2011 Author Share Posted June 29, 2011 Yes, i started this a few minutes ago, just have this part of code and i have created a table with one field only. Once i get it working i will do the rest. Thanks for you reply Link to comment https://forums.phpfreaks.com/topic/240698-storing-and-retrieving-files-into-postgresql-or-mysql/#findComment-1236286 Share on other sites More sharing options...
thales.pereira Posted June 29, 2011 Author Share Posted June 29, 2011 Sorry the double post, but anyone belive this is a better solution? instead storing the file, i could store the information of the file into a field, and when i need it i could extract the data to a local file. <?xml version="1.0" encoding="UTF-8"?> <Values version="2.0"> <value name="node_type">ConnectionData</value> <value name="node_nsName">Adapters:Qry</value> <value name="node_pkg">Adapters</value> <value name="IRTNODE_VERSION">1</value> <value name="IRTNODE_PROPERTY">CwQAAAABBQEEGQBjAG8AbQAuAHcAbQAuAGQAYQB0AGEALgBJAFMATQBlAG0ARABhAHQAYQBJAG0AcABsBBUAYwBvAG4AbgBlAGMAdABpAG8AbgBOAG8AZABlAFYAZQByAHMAaQBvAG4LBAAAAAEEDwBhAGQAYQBwAHQAZQByAFQAeQBwAGUATgBhAG0AZQQLAEoARABCAEMAQQBkAGEAcAB0AGUAcgQZAGMAbwBuAG4AZQBjAHQAaQBvAG4ARgBhAGMAdABvAHIAeQBUAHkAcABlAE4AYQBtAGUENgBjAG8AbQAuAHcAbQAuAGEAZABhAHAAdABlAHIALgB3AG0AagBkAGIAYwAuAGMAbwBuAG4AZQBjAHQAaQBvAG4ALgBKAEQAQgBDAEMAbwBuAG4AZQBjAHQAaQBvAG4ARgBhAGMAdABvAHIAeQQUAGMAbwBuAG4AZQBjAHQAaQBvAG4AUAByAG8AcABlAHIAdABpAGUAcwUBAAIEDwB0AHIAYQBuAHMAYQBjAHQAaQBvAG4AVAB5AHAAZQQOAE4ATwBfAFQAUgBBAE4AUwBBAEMAVABJAE8ATgQPAGQAYQB0AGEAcwBvAHUAcgBjAGUAQwB</value> </Values> Sugestions? Link to comment https://forums.phpfreaks.com/topic/240698-storing-and-retrieving-files-into-postgresql-or-mysql/#findComment-1236297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.