X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 92EB59DC886 for ; Thu, 29 Dec 2005 15:32:14 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86951-03 for ; Thu, 29 Dec 2005 15:32:14 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 8C1B99DC88C for ; Thu, 29 Dec 2005 15:32:12 -0400 (AST) Received: from mail.ydreams.com (unknown [213.63.136.50]) by svr4.postgresql.org (Postfix) with ESMTP id 579CF5AF039 for ; Thu, 29 Dec 2005 19:32:13 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by mail.ydreams.com (Postfix) with ESMTP id 8583ABD4F for ; Thu, 29 Dec 2005 19:32:11 +0000 (WET) Received: from mail.ydreams.com ([127.0.0.1]) by localhost (mail1.ydreams.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05042-06 for ; Thu, 29 Dec 2005 19:32:02 +0000 (WET) Received: from [172.17.14.165] (yd170.ydreams.com [172.17.14.165]) by mail.ydreams.com (Postfix) with ESMTP id EA3DBBDED for ; Thu, 29 Dec 2005 19:32:02 +0000 (WET) Message-ID: <43B439B0.40401@ydreams.com> Date: Thu, 29 Dec 2005 19:32:00 +0000 From: ivan valadares User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-php@postgresql.org Subject: SAVE AND RESTORE FILES TO POSTGRESQL (PHP CLASS) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at ydreams.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.583 required=5 tests=[AWL=-0.583, SUBJ_ALL_CAPS=1.166] X-Spam-Score: 0.583 X-Spam-Level: X-Archive-Number: 200512/25 X-Sequence-Number: 3371 -------- Database ---------------- CREATE TABLE images ( name text, image oid, filesize bigint ); ---------- File to Database Exemple ------------ include("image.php"); $filetosave="HPIM0551.JPG" // file to save in the database $loId = addImage($conn,$filetosave); $id_Desc = $filetosave; $fsize=filesize("HPIM0551.JPG"); $sql = "INSERT INTO images(name,value,filesize) VALUES('$id_Desc','$loId','$fsize')"; pg_query($sql); -------- Database to Files Exemple ------------ include("image.php"); $sql = "Select value,name,filesize FROM images"; $res = Query($conn,$sql); $dir = "C:\\images\\"; // directory while(Fetch($res)) { if (Cell($res,2)) { WriteImageToFile(Cell($res,0),$dir.Cell($res,1),Cell($res,2)); } }