X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 97DBAD1B48B for ; Wed, 7 Jan 2004 22:06:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 07580-04 for ; Wed, 7 Jan 2004 18:05:26 -0400 (AST) Received: from gomez.justsportsusa.com (unknown [208.29.195.72]) by svr1.postgresql.org (Postfix) with ESMTP id 5D256D1B4C1 for ; Wed, 7 Jan 2004 18:05:18 -0400 (AST) Received: from ehpg.net (gavin.justsportsusa.com [192.168.254.20] (may be forged)) by gomez.justsportsusa.com (8.12.9/8.12.4) with ESMTP id i07M12WD013128; Wed, 7 Jan 2004 14:01:03 -0800 Message-ID: <3FFC820B.3060202@ehpg.net> Date: Wed, 07 Jan 2004 14:02:51 -0800 From: "Gavin M. Roy" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mike Nolan Cc: pgsql-php@postgresql.org Subject: Re: [GENERAL] PHP arrays and postgresql References: <200401072045.i07Kjm2E022477@gw.tssi.com> In-Reply-To: <200401072045.i07Kjm2E022477@gw.tssi.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/5 X-Sequence-Number: 2521 create table test( t_value text; ); $array_values[] = "Test 1"; $array_values[] = "Test 2"; $array_values[] = "Test 3"; pg_Query($conn, "INSERT INTO test VALUES ( '" . base64_encode(seralize($array_values)) . "' );"); $result = pg_Query($conn, "SELECT * FROM test;"); $rows = pg_NumRows($result) for ( $y = 0; $y < $rows; $y++ ) { $data = unserialize(base64_decode(pg_Result($result, $y, 0))); print_r($data); } pg_FreeResult($result); Hope this helps (serialize, unserialize). I use base64_encode/decode to ensure that there wont be any delimiter problems, could be achieved by using addslashes as well. Gavin Mike Nolan wrote: >This may not be the best place to ask the question, but I've already searched >the PHP archive and code snippet sites. > >I'm trying to find a way to store and then retrieve a PHP array in >my pg database. > >Has anyone written some code to do this? >-- >Mike Nolan > >---------------------------(end of broadcast)--------------------------- >TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > >