Re: PHP array to PlPgSQL arrat. How to?

From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Andre Lopes <lopes80andre(at)gmail(dot)com>, postgresql Forums <pgsql-general(at)postgresql(dot)org>
Subject: Re: PHP array to PlPgSQL arrat. How to?
Date: 2011-03-05 19:48:09
Message-ID: AANLkTindKvJLT-MQ9M9brT-Fq01YXC-wAjumDsVSd11L@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2011/3/5 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>

> 2011/3/5 Andre Lopes <lopes80andre(at)gmail(dot)com>:
> > Hi Pavel,
> >
> > Thanks for the reply.
> >
> > In PlpgSQL there is possible to define arrays with "Key => Value, Key =>
> Value"?
> >
>
> No, no directly
>
> there are no hash array
>
> there is a workaround a hstore module
>
Why hstore is a workaround ? hstore is a proven and
mature module.
And since 9.0 is has a lot of improvements and
make the life easy in some cases today and here.

>
> http://www.postgresql.org/docs/9.0/static/hstore.html
>
> attention - it doesn't allow a nested values
>
> Regards
>
> Pavel Stehule
>
> for more complex values is other was - using a temp tables - you can
> fill a temp table and in next step a plpgsql code use this temp table.
> But it should have a performance impacts.
>
>
>
> > Best Regards,
> >
> >
> > On Sat, Mar 5, 2011 at 7:28 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
> >> Hello
> >>
> >> there isn't a simple way :(
> >>
> >> the most simply way is using string_to_array function
> >>
> >> SELECT func(string_to_array('1,2,3,4,5',','));
> >>
> >> Regards
> >>
> >> Pavel Stehule
> >>
> >>
> >> 2011/3/5 Andre Lopes <lopes80andre(at)gmail(dot)com>:
> >>> Hi,
> >>>
> >>> I need to transform an PHP array to an PlPgSQL array. The PHP array is
> >>> like this:
> >>>
> >>> [quote]
> >>> $arr = array(
> >>> 0 => array(
> >>> "base64" =>
> "ddfffffff",
> >>> "image_type" =>
> "jpg",
> >>> "width" =>
> "343",
> >>> "height" =>
> "515",
> >>>
> "html_width_height" => 'width="343" height="515"',
> >>> "mime" =>
> "image/jpeg"
> >>> ),
> >>> 1 => array(
> >>> "base64" =>
> "ddfffffffddddd",
> >>> "image_type" =>
> "jpg",
> >>> "width" =>
> "343",
> >>> "height" =>
> "515",
> >>>
> "html_width_height" => 'width="343" height="515"',
> >>> "mime" =>
> "image/jpeg"
> >>> )
> >>> );
> >>> [/quote]
> >>>
> >>> How can I pass this kinf of PHP array to PlPgSQL?
> >>>
> >>> Give me a clue.
> >>>
> >>> Best Regards,
> >>>
> >>> --
> >>> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> >>> To make changes to your subscription:
> >>> http://www.postgresql.org/mailpref/pgsql-general
> >>>
> >>
> >
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
// Dmitriy.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andre Lopes 2011-03-05 19:48:38 Re: PHP array to PlPgSQL arrat. How to?
Previous Message Pavel Stehule 2011-03-05 19:42:54 Re: PHP array to PlPgSQL arrat. How to?