From: Jean-Christophe Roux <jcxxr@yahoo.com>
To: pgsql-php@postgresql.org
Subject: plpgsql returning array
Date: Sat, 14 Oct 2006 13:28:41 -0700 (PDT)
Message-ID: <20061014202841.17630.qmail@web35304.mail.mud.yahoo.com> (raw)
Hello,
in Postgresql, I have a function like this
CREATE OR REPLACE FUNCTION foo()
RETURNS text[] AS
$BODY$
declare
a text;
b text;
arr text[];
begin
a = 'a';
b = 'b';
arr[0] = a;
arr[1] = b;
return arr;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
In PHP I would like to read my returned arr.
<?php
$message = pg_fetch_result(pg_query("select foo()"),0,0);
print_r($message);
?>
prints something like:
[0:1]={a,b}
I could parse that results, as a string but I'd rather have a nice array. Any idea how I should change the function and/or the php codes?
Thanks in advance
Jean
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: jcxxr@yahoo.com
Subject: Re: plpgsql returning array
In-Reply-To: <20061014202841.17630.qmail@web35304.mail.mud.yahoo.com>
References: <20061014202841.17630.qmail@web35304.mail.mud.yahoo.com>
* 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