Re: Database/Table Design for Global Country Statistics

From: Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Database/Table Design for Global Country Statistics
Date: 2007-09-13 12:16:03
Message-ID: 62A8F986-2813-44AE-B828-98B0502FA746@grid.unep.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> $curr_yr = -1
> $cols = array();
> while (<fetch rows>) {
> if ($row['year'] != $curr_yr) {
> if (sizeof($cols) > 0) { display_table_row($cols); }
> $cols = array();
> $curr_year = $row['year'];
> }
> $cols[] = $row['value'];
> }
> // handle possible last row of table
> if (sizeof($cols) > 0) { display_table_row($cols); }
>

Thanks for the code. I got it working with a couple of changes. But
then I realized that with the new table design I can't anymore easily
sort by a given year (1970 or 2000). This is surely one of the
advantages of the "old" design, that the use via PHP was quite
straight forward.

Do I have to transfer the query results into a PHP array to sort it
in there, then?

Thanks for any hints!

Stef

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2007-09-13 12:16:24 Re: Cannot declare record members NOT NULL
Previous Message Cultural Sublimation 2007-09-13 12:06:40 Re: Cannot declare record members NOT NULL