Skip site navigation (1) Skip section navigation (2)

plpgsql returning array

From: Jean-Christophe Roux <jcxxr(at)yahoo(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: plpgsql returning array
Date: 2006-10-14 20:28:41
Message-ID: 20061014202841.17630.qmail@web35304.mail.mud.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-php
Hello,
in Postgresql, I have a function like this

CREATE OR REPLACE FUNCTION foo()
  RETURNS text[] AS
$BODY$
declare
    a text;
    b text;
    arr text[];
begin
    a = 'a';
    b = 'b';
    arr[0] = a;
    arr[1] = b;
    return arr;
end;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

In PHP I would like to read my returned arr.
<?php
            $message = pg_fetch_result(pg_query("select foo()"),0,0);
            print_r($message);
?>
prints something like:
[0:1]={a,b}


I could parse that results, as a string but I'd rather have a nice array. Any idea how I should change the function and/or the php codes? 
Thanks in advance
Jean



Responses

pgsql-php by date

Next:From: Marc McIntyreDate: 2006-10-15 06:11:30
Subject: Re: plpgsql returning array
Previous:From: ben wilkoDate: 2006-10-14 04:57:54
Subject: Re: Tutorial/Example of Insert/Select PDF Postgres DB ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group