logo       

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

Subject: Re: array fields in the database and their handling with php4
Hi Matthias,

On Monday, Oct 27, 2003, at 00:04 Asia/Tokyo, Matthias Weinhold wrote:
i have a table 'mitarbeiter' in my database, column 'Abteilung' is an
array{'Abteilung1, Abteilung2'}, because some people work in more than
one section.

I'm not an expert by any means, but I guess I would recommend using a different set up for this. I don't know if using an array is the best way for this situation. I remember reading somewhere that arrays should really only be used for data that is naturally in an array form. (Plus, I don't know how to use arrays either! :)

If you can still change the database, I'd recommend making another table 'abteilung' and drop the 'abteilung' column from 'mitarbeiter'.

The new set up would be this:
table mitarbeiter (name)
table abteilung (name references mitarbeiter(name), abteilung)

Then a query that would return a table with name and abteilung would look like

SELECT m.name, a.abteilung FROM mitarbeiter as m, abteilung as a where m.name = 'D. Brenner';

I'm using 'name' as the primary key for mitarbeiter. If you've got a different primary key (like 'id'), reference that instead of 'name' in table 'abteilung'.

If you only want one row per name in the query result, I think you could make a function that would return a list of all abteilung for a given 'name'. However, you can do this kind of formatting in PHP just as easily.

When you read the results in via PHP, you can take the name from the first row to make the first row of your html table. Then take the 'abteilung' from the first (and possibly subsequent) rows of the result to make the second (and subsequent) rows of the html table.

I'm sorry I can't give you specific help on arrays. Hopefully this will help.

Michael


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe