pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedPHP arrays and postgresql
4+ messages / 3 participants
[nested] [flat]
* PHP arrays and postgresql
@ 2004-01-07 20:45 Mike Nolan <nolan@gw.tssi.com>
2004-01-07 21:59 ` Re: PHP arrays and postgresql Richard Huxton <dev@archonet.com>
2004-01-07 22:02 ` Re: [GENERAL] PHP arrays and postgresql Gavin M. Roy <gmr@ehpg.net>
0 siblings, 2 replies; 4+ messages in thread
From: Mike Nolan @ 2004-01-07 20:45 UTC (permalink / raw)
To: pgsql-general@postgresql.org
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: PHP arrays and postgresql
2004-01-07 20:45 PHP arrays and postgresql Mike Nolan <nolan@gw.tssi.com>
@ 2004-01-07 21:59 ` Richard Huxton <dev@archonet.com>
2004-01-08 00:23 ` Re: PHP arrays and postgresql Mike Nolan <nolan@gw.tssi.com>
1 sibling, 1 reply; 4+ messages in thread
From: Richard Huxton @ 2004-01-07 21:59 UTC (permalink / raw)
To: Mike Nolan <nolan@gw.tssi.com>; pgsql-general@postgresql.org
On Wednesday 07 January 2004 20:45, Mike Nolan wrote:
> I'm trying to find a way to store and then retrieve a PHP array in
> my pg database.
If you mean as one value, look into the serialise() function - that's probably
what you want.
If not, can you explain a little more?
--
Richard Huxton
Archonet Ltd
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: PHP arrays and postgresql
2004-01-07 20:45 PHP arrays and postgresql Mike Nolan <nolan@gw.tssi.com>
2004-01-07 21:59 ` Re: PHP arrays and postgresql Richard Huxton <dev@archonet.com>
@ 2004-01-08 00:23 ` Mike Nolan <nolan@gw.tssi.com>
0 siblings, 0 replies; 4+ messages in thread
From: Mike Nolan @ 2004-01-08 00:23 UTC (permalink / raw)
To: dev@archonet.com; +Cc: pgsql-general@postgresql.org
> > I'm trying to find a way to store and then retrieve a PHP array in
> > my pg database.
>
> If you mean as one value, look into the serialise() function - that's probably
> what you want.
Serialize is just what I was looking for but not coming up with.
(My 18 year old son just got a kick out of the answer, he doesn't know
PHP but when I was explaining the problem to him last night he said,
"You mean like 'serialize' in Javascript?")
Thanks to everyone who responded.
--
Mike Nolan
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [GENERAL] PHP arrays and postgresql
2004-01-07 20:45 PHP arrays and postgresql Mike Nolan <nolan@gw.tssi.com>
@ 2004-01-07 22:02 ` Gavin M. Roy <gmr@ehpg.net>
1 sibling, 0 replies; 4+ messages in thread
From: Gavin M. Roy @ 2004-01-07 22:02 UTC (permalink / raw)
To: Mike Nolan <nolan@gw.tssi.com>; +Cc: pgsql-php
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)
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2004-01-08 00:23 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-01-07 20:45 PHP arrays and postgresql Mike Nolan <nolan@gw.tssi.com>
2004-01-07 21:59 ` Richard Huxton <dev@archonet.com>
2004-01-08 00:23 ` Mike Nolan <nolan@gw.tssi.com>
2004-01-07 22:02 ` Gavin M. Roy <gmr@ehpg.net>
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