Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VerhD-00013x-Vy for pgsql-php@arkaria.postgresql.org; Fri, 08 Nov 2013 19:26:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VerhD-0003Zf-Fl for pgsql-php@arkaria.postgresql.org; Fri, 08 Nov 2013 19:26:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VerhC-0003ZZ-Ku for pgsql-php@postgresql.org; Fri, 08 Nov 2013 19:26:18 +0000 Received: from mail-ea0-x236.google.com ([2a00:1450:4013:c01::236]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Verh9-0007qD-9s for pgsql-php@postgresql.org; Fri, 08 Nov 2013 19:26:18 +0000 Received: by mail-ea0-f182.google.com with SMTP id o10so1348225eaj.27 for ; Fri, 08 Nov 2013 11:26:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=YJy43eninOBEJ7H3JqjLeN1+TgcJI6okphPpCR9nMxM=; b=NJUABF7AQ5La/KiapCeVRohlESuyBtMFJJBcHoDaeugsOW4RyWF5yOcYMr8T27WJEL c81Eei886/XeMAw57XsPtWMd7Me9g5nFx7AF92kTHzeartvPp/+sBMBulAwyzdGs/i5L b5lWhLnOILS3LaaCvXC07fbxYKKCtoytF/pA2Ugb3EaItZDM8ivFkwwA1vfjoViAEu07 YJf1YooWzU3zqz5KCr56XQ+YFxz53+6hpE+SEiEbrjO93XOFfQfRQDbS+J7k7eKgsHEZ P51aLlEoT+kkpVjMwQRz/zLGhDryYRdSe1Mf9J+axLF8vrdBhl+CwIwxnEjwmh46JSvM OWnA== X-Received: by 10.14.210.8 with SMTP id t8mr18486781eeo.39.1383938774261; Fri, 08 Nov 2013 11:26:14 -0800 (PST) Received: from [192.168.178.35] (byrt-4d0719cc.pool.mediaWays.net. [77.7.25.204]) by mx.google.com with ESMTPSA id b42sm26422395eem.9.2013.11.08.11.26.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Nov 2013 11:26:13 -0800 (PST) Message-ID: <527D3AD4.1090808@gmail.com> Date: Fri, 08 Nov 2013 20:26:12 +0100 From: Michael Schmidt User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: "Jonah H. Harris" CC: pgsql-php@postgresql.org Subject: Re: PHP PDO getting data from pgSQL stored function References: <5275203C.2090007@gmail.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------090705030905020809030909" X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-php Precedence: bulk Sender: pgsql-php-owner@postgresql.org This is a multi-part message in MIME format. --------------090705030905020809030909 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, sorry for the late response. I did it with the solution posted by Jonah. It is not necessary for me to return a table(...) because i want to return the structure which is already defined in my database so i can use SETOF RECORD as return type. So i use the real table to define the return of my function. PDO select works just like a normal select on a table. Thank you. Am 03.11.2013 17:06, schrieb Jonah H. Harris: > On Sat, Nov 2, 2013 at 11:54 AM, Michael Schmidt > wrote: > > i need to do a ugly select which i dont want to place in my php code. > I use PDO all the time. > > > All database access from our application is functionalized using > either PL/pgSQL or SQL functions. > > I want to return a structure which is the same as a table i have > created. > > > CREATE FUNCTION blah (IN param 1, ..., IN param n, OUT param 1, ... > OUT param n) RETURNS SETOF RECORD > > Now my question, how can i return that and access it with PHP PDO? > Should I use a cursor or shoul I use the return of the function > (if it is possible)? > > > Just do a SELECT * FROM blah(...); as a normal PDO query. > > -- > Jonah H. Harris > Blog: http://www.oracle-internals.com/ --------------090705030905020809030909 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
Hi,

sorry for the late response.

I did it with the solution posted by Jonah.

It is not necessary for me to return a table(...) because i want to return the structure which is already defined in my database so i can use SETOF RECORD as return type. So i use the real table to define the return of my function.

PDO select works just like a normal select on a table.

Thank you.

Am 03.11.2013 17:06, schrieb Jonah H. Harris:
On Sat, Nov 2, 2013 at 11:54 AM, Michael Schmidt <css.liquid@gmail.com> wrote:
i need to do a ugly select which i dont want to place in my php code.
I use PDO all the time.

All database access from our application is functionalized using either PL/pgSQL or SQL functions.
 
I want to return a structure which is the same as a table i have created.

CREATE FUNCTION blah (IN param 1, ..., IN param n, OUT param 1, ... OUT param n) RETURNS SETOF RECORD

Now my question, how can i return that and access it with PHP PDO?
Should I use a cursor or shoul I use the return of the function (if it is possible)?

Just do a SELECT * FROM blah(...); as a normal PDO query.

--
Jonah H. Harris
Blog: http://www.oracle-internals.com/

--------------090705030905020809030909--