From: | Alan Hodgson <ahodgson(at)simkin(dot)ca> |
---|---|
To: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: function with array parameter |
Date: | 2006-11-08 20:29:57 |
Message-ID: | 200611081229.57318@hal.medialogik.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
> On 11/9/06, Jean-Christophe Roux <jcxxr(at)yahoo(dot)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 /.
From | Date | Subject | |
---|---|---|---|
Next Message | Steven Osborn | 2006-11-08 21:06:50 | unsubscribe |
Previous Message | Talha Khan | 2006-11-08 20:25:29 | Re: function with array parameter |