From: Alan Hodgson <ahodgson@simkin.ca>
To: pgsql-php@postgresql.org
Subject: Re: function with array parameter
Date: Wed, 8 Nov 2006 12:29:57 -0800
Message-ID: <200611081229.57318@hal.medialogik.com> (raw)
In-Reply-To: <f80885fc0611081225h3ff97898n2afde937dc4067a3@mail.gmail.com>
References: <20061108200724.43283.qmail@web35311.mail.mud.yahoo.com>
<f80885fc0611081225h3ff97898n2afde937dc4067a3@mail.gmail.com>
> On 11/9/06, Jean-Christophe Roux <jcxxr@yahoo.com> wrote:
> > Hello,
> > I have a function that I would like to call from a php script:
> >
> > CREATE OR REPLACE FUNCTION a_dummy(arr_in text[])
> > RETURNS text AS
> > $BODY$
> > declare
> > begin
> > return arr_in[1];
> > end;
> > $BODY$
> > LANGUAGE 'plpgsql' VOLATILE;
> >
> > and the php code would be something like that
> > $arr;
> > $arr[0] = "one";
> > $arr[1] = 'two';
> > $query = "select func_a_dummy($arr)";
> > $result = pg_query($query);
> > echo pg_fetch_result($result, 0, 0);
A PHP array doesn't translate to a PostgreSQL array. You have to build up a
string to pass to the function ( ie. '{"value1","value2"}' ) .
--
"Emacs is great. But hang onto vim, because you'll still need a decent
text editor." - seen on /.
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: ahodgson@simkin.ca
Subject: Re: function with array parameter
In-Reply-To: <200611081229.57318@hal.medialogik.com>
References: <20061108200724.43283.qmail@web35311.mail.mud.yahoo.com> <f80885fc0611081225h3ff97898n2afde937dc4067a3@mail.gmail.com> <200611081229.57318@hal.medialogik.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