From: Gavin M. Roy <gmr@ehpg.net>
To: Mike Nolan <nolan@gw.tssi.com>
Cc: pgsql-php@postgresql.org
Subject: Re: [GENERAL] PHP arrays and postgresql
Date: Wed, 07 Jan 2004 14:02:51 -0800
Message-ID: <3FFC820B.3060202@ehpg.net> (raw)
In-Reply-To: <200401072045.i07Kjm2E022477@gw.tssi.com>
References: <200401072045.i07Kjm2E022477@gw.tssi.com>
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)
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: gmr@ehpg.net, nolan@gw.tssi.com
Subject: Re: [GENERAL] PHP arrays and postgresql
In-Reply-To: <3FFC820B.3060202@ehpg.net>
References: <200401072045.i07Kjm2E022477@gw.tssi.com> <3FFC820B.3060202@ehpg.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox