Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id CBB079FA1FD for ; Wed, 8 Nov 2006 16:30:04 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 08549-06 for ; Wed, 8 Nov 2006 16:30:01 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from skynet.simkin.ca (skynet.simkin.ca [199.175.137.210]) by postgresql.org (Postfix) with ESMTP id CA8CD9FA17A for ; Wed, 8 Nov 2006 16:30:00 -0400 (AST) Received: from hal.simkin.ca (S0106000c6eb33e73.vc.shawcable.net [24.80.109.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by skynet.simkin.ca (Postfix) with ESMTP id 021C2FAC5 for ; Wed, 8 Nov 2006 12:29:58 -0800 (PST) From: Alan Hodgson Organization: Simkin Network Consulting To: pgsql-php@postgresql.org Subject: Re: function with array parameter Date: Wed, 8 Nov 2006 12:29:57 -0800 User-Agent: KMail/1.9.1 References: <20061108200724.43283.qmail@web35311.mail.mud.yahoo.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200611081229.57318@hal.medialogik.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/21 X-Sequence-Number: 3638 > On 11/9/06, Jean-Christophe Roux 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 /.