Re: array fields in the database and their handling with php4

From: Adam Witney <awitney(at)sghms(dot)ac(dot)uk>
To: Matthias Weinhold <Matthias(dot)Weinhold(at)gmx(dot)net>, pgsql-php <pgsql-php(at)postgresql(dot)org>
Subject: Re: array fields in the database and their handling with php4
Date: 2003-10-27 08:59:18
Message-ID: BBC28EE6.270C7%awitney@sghms.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php


I'm not quite sure if this is what you are after, but if you are asking how
to use a PostgreSQL array in php then it just comes in as a string, I then
use this function to turn it into a php array

function pg_array_php($array)
{
$new_array = explode(",", ereg_replace("[{-}]", "", $array));

return $new_array;
}

> Hey,
>
> i have a table 'mitarbeiter' in my database, column 'Abteilung' is an
> array{'Abteilung1, Abteilung2'}, because some people work in more than
> one section. Now i will print the results from a query like
>
> SELECT name, abteilung[1], abteilung[2],FROM mitarbeiter WHERE name =
> D. Benner;
>
> to an html-table via php in this form:
>
> Name | Benner
> -------------------
> Abteilung 1 | abt_1
> -------------------
> Abteilung 2 | abt_2
>
> I don't no how to handle the array-field in the database? Any hints?
>
> Greetings from cold germany Matthias

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Mariusz Pekala 2003-10-27 19:56:22 Re: Saving result to file for download
Previous Message zen31329 2003-10-26 18:56:11 Re: array fields in the database and their handling with php4