Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 5B9D99FB277 for ; Wed, 8 Nov 2006 17:30:39 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 81983-07 for ; Wed, 8 Nov 2006 21:30:23 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web35301.mail.mud.yahoo.com (web35301.mail.mud.yahoo.com [66.163.179.95]) by postgresql.org (Postfix) with SMTP id AF1D09FA17A for ; Wed, 8 Nov 2006 17:30:23 -0400 (AST) Received: (qmail 62183 invoked by uid 60001); 8 Nov 2006 21:30:22 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:MIME-Version:Content-Type; b=iUAXj3RTUbCKozUmEoEX8FrveoTIlWhViyz6U6L92iJCFuXtFKFxrB4RxYBY7zcbxhiVkwoe8WNKZgQOgXBnT1SD5+ZZMBb2WJMQgIAvDWJ66AcptCMf69+/vJWrfjLI7qaeWvHcl43Por85TtzMAfqme5UzHc349ZIPI0qpK3Q= ; Message-ID: <20061108213022.62179.qmail@web35301.mail.mud.yahoo.com> Received: from [74.98.189.48] by web35301.mail.mud.yahoo.com via HTTP; Wed, 08 Nov 2006 13:30:22 PST Date: Wed, 8 Nov 2006 13:30:22 -0800 (PST) From: Jean-Christophe Roux Subject: Re: function with array parameter To: Talha Khan Cc: pgsql-php@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1675484758-1163021422=:62120" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/22 X-Sequence-Number: 3639 --0-1675484758-1163021422=:62120 Content-Type: text/plain; charset=ascii Content-Transfer-Encoding: quoted-printable Hello,=0A=0AThanks for the answer but the resource connection is optional a= nd in this script there is no ambiguity since there is only one connection.= I added the connection to pg_query any way and the script still fails. I w= ent through archives and saw that others had the same problem with using a = PHP arrays as a parameter to a Postgresql function. I have not found a solu= tion though; any thought?=0A=0A----- Original Message ----=0AFrom: Talha Kh= an =0ATo: Jean-Christophe Roux =0AC= c: pgsql-php@postgresql.org=0ASent: Wednesday, November 8, 2006 3:25:29 PM= =0ASubject: Re: [PHP] function with array parameter=0A=0AHi Jean,=0A=0A>>$r= esult =3D pg_query($query);=0A=0Atry it as follows=0A=0A$result=3Dpg_query(= $database,$query);=0A=0Awhere=0A=0A$database=3D=0A=0ARegards= ,=0A=0ATalha Khan=0A=0AOn 11/9/06, Jean-Christophe Roux w= rote:=0AHello,=0AI have a function that I would like to call from a php scr= ipt:=0A=0ACREATE OR REPLACE FUNCTION a_dummy(arr_in text[])=0A=0A RETURNS = text AS=0A$BODY$=0Adeclare=0Abegin=0A return arr_in[1];=0Aend;=0A$BODY$= =0A LANGUAGE 'plpgsql' VOLATILE;=0A=0Aand the php code would be something = like that=0A$arr;=0A$arr[0] =3D "one";=0A$arr[1] =3D 'two';=0A=0A$query =3D= "select func_a_dummy($arr)";=0A$result =3D pg_query($query);=0Aecho pg_fet= ch_result($result, 0, 0);=0A=0A=0Abut the syntax is wrong. Any idea what I = should do to make it work=0AThank you=0A=0A=0A=0A=0A=0A=0A=0A=0A=0A=0A=0A= =0A=0A=0A --0-1675484758-1163021422=:62120 Content-Type: text/html; charset=ascii Content-Transfer-Encoding: quoted-printable
Hello,

Thanks for the answer but the resourc= e connection is optional and in this script there is no ambiguity since the= re is only one connection. I added the connection to pg_query any way and t= he script still fails. I went through archives and saw that others had the = same problem with using a PHP arrays as a parameter to a Postgresql functio= n. I have not found a solution though; any thought?

----- Or= iginal Message ----
From: Talha Khan <talha.amjad@gmail.com>
To= : Jean-Christophe Roux <jcxxr@yahoo.com>
Cc: pgsql-php@postgresql.= org
Sent: Wednesday, November 8, 2006 3:25:29 PM
Subject: Re: [PHP] f= unction with array parameter

Hi Jean,

>>$result =3D pg_query($query);
=
try it as follows

$result=3Dpg_query($database,$query);

w= here

$database=3D<database name>

Regards,
=0ATalha Khan

On 11/9/06, Jean-Christophe Roux <jcxxr@yahoo.com> wrote:
=0A
Hello,
I have a function that I would like to call from a php script:=

CREATE OR REPLACE FUNCTION a_dummy(arr_in text[])
=0A  RETU= RNS 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] =3D "one";$arr[1] =3D 'two';=0A
$query =3D "select func_a_dummy($arr)";
$resul= t =3D pg_query($query);
echo pg_fetch_result($result, 0, 0);


= but the syntax is wrong. Any idea what I should do to make it work
Thank= you
=0A

=0A

=0A


--0-1675484758-1163021422=:62120--