Lists: | pgsql-general |
---|
From: | Yannick Warnier <ywarnier(at)beeznest(dot)org> |
---|---|
To: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | PHP and Postgres arrays |
Date: | 2008-01-18 22:01:09 |
Message-ID: | 1200693669.9992.457.camel@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Hello,
I've been searching (not very thoroughly, but still) for a way to get
Postgres arrays right into PHP arrays, but it seems that the Postgres
driver simply doesn't allow that.
The only solution seems to use some user-defined functions[1] to split
the result of a query (a string) into a PHP array.
Some Perl-related readings [2] seem to say that Postgres actually
provides a string, loosing the possibility to get it as an array, but
these comments date back to 2005.
Any chance someone around here might tell me more about this and
possibly give me some better way to get those arrays than copy-pasting
the user-proposed PHP functions?
Thanks,
Yannick Warnier
[1] http://www.php.net/manual/en/ref.pgsql.php#58660
[2] http://www.perlmonks.org/?node_id=474518
From: | Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: PHP and Postgres arrays |
Date: | 2008-01-18 22:10:59 |
Message-ID: | 20080118231059.7842b847@webthatworks.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On Fri, 18 Jan 2008 23:01:09 +0100
Yannick Warnier <ywarnier(at)beeznest(dot)org> wrote:
> Hello,
> I've been searching (not very thoroughly, but still) for a way to
> get Postgres arrays right into PHP arrays, but it seems that the
> Postgres driver simply doesn't allow that.
What about using a stored procedure to return the array as a joined
row?
--
Ivan Sergio Borgonovo
http://www.webthatworks.it
From: | Yannick Warnier <ywarnier(at)beeznest(dot)org> |
---|---|
To: | Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: PHP and Postgres arrays |
Date: | 2008-01-18 22:29:17 |
Message-ID: | 1200695357.9992.463.camel@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Le vendredi 18 janvier 2008 à 23:10 +0100, Ivan Sergio Borgonovo a
écrit :
> On Fri, 18 Jan 2008 23:01:09 +0100
> Yannick Warnier <ywarnier(at)beeznest(dot)org> wrote:
>
> > Hello,
>
> > I've been searching (not very thoroughly, but still) for a way to
> > get Postgres arrays right into PHP arrays, but it seems that the
> > Postgres driver simply doesn't allow that.
>
> What about using a stored procedure to return the array as a joined
> row?
I thought about it, but it's not very portable if you want to ship a PHP
application. But I admit I will fall back to that solution if I cannot
find any other (considering PostgreSQL might be the only open-source
database to offer in-fields arrays anyway).
Yannick
From: | Hannes Dorbath <light(at)theendofthetunnel(dot)de> |
---|---|
To: | Yannick Warnier <ywarnier(at)beeznest(dot)org> |
Subject: | Re: PHP and Postgres arrays |
Date: | 2008-01-18 23:40:01 |
Message-ID: | 479138D1.8060500@theendofthetunnel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Yannick Warnier wrote:
> I thought about it, but it's not very portable if you want to ship a PHP
> application. But I admit I will fall back to that solution if I cannot
> find any other (considering PostgreSQL might be the only open-source
> database to offer in-fields arrays anyway).
You can use the build in function array_to_string:
http://www.postgresql.org/docs/8.3/static/functions-array.html
--
Best regards,
Hannes Dorbath
From: | brian <brian(at)zijn-digital(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: PHP and Postgres arrays |
Date: | 2008-01-19 00:15:33 |
Message-ID: | 47914125.3010704@zijn-digital.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Hannes Dorbath wrote:
> Yannick Warnier wrote:
>> I thought about it, but it's not very portable if you want to ship a PHP
>> application. But I admit I will fall back to that solution if I cannot
>> find any other (considering PostgreSQL might be the only open-source
>> database to offer in-fields arrays anyway).
>
> You can use the build in function array_to_string:
> http://www.postgresql.org/docs/8.3/static/functions-array.html
>
Then use implode(YOUR_DELIMITER, YOUR_STRING) to get an array.
Another solution would be to use the MDB2 (or similar) PEAR wrapper.
b