Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 9204E9FA1FD for ; Wed, 8 Nov 2006 16:25:34 -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 07079-05 for ; Wed, 8 Nov 2006 16:25:31 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.168]) by postgresql.org (Postfix) with ESMTP id 639E19FA17A for ; Wed, 8 Nov 2006 16:25:31 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id k3so11485ugf for ; Wed, 08 Nov 2006 12:25:29 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=oZ6WeYauJmdc9St7m0clPZ2uag6ObeNEkNf6tS61wKfdp+avvzyRuP6Ic6bPyVRPGOQOYrH5hxsslhTYaeu9uYXy93LznzPHolre3vu/FzWa3X9kOlkss3U3sD4u9oNZ/QVwD03Cvl0Lcfvw56yYfBa2cUs3c/pNTBcLfRQDuSs= Received: by 10.82.129.8 with SMTP id b8mr6440bud.1163017529535; Wed, 08 Nov 2006 12:25:29 -0800 (PST) Received: by 10.82.158.7 with HTTP; Wed, 8 Nov 2006 12:25:29 -0800 (PST) Message-ID: Date: Thu, 9 Nov 2006 01:25:29 +0500 From: "Talha Khan" To: "Jean-Christophe Roux" Subject: Re: function with array parameter Cc: pgsql-php@postgresql.org In-Reply-To: <20061108200724.43283.qmail@web35311.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_27610_9570405.1163017529444" References: <20061108200724.43283.qmail@web35311.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/20 X-Sequence-Number: 3637 ------=_Part_27610_9570405.1163017529444 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Jean, >>$result = pg_query($query); try it as follows $result=pg_query($database,$query); where $database= Regards, Talha Khan 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); > > > but the syntax is wrong. Any idea what I should do to make it work > Thank you > > ------=_Part_27610_9570405.1163017529444 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Jean,

>>$result = pg_query($query);

try it as follows

$result=pg_query($database,$query);

where

$database=<database name>

Regards,
Talha Khan

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);


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


------=_Part_27610_9570405.1163017529444--