Re: DESIGN CONCEPT (performance) - switch/arrays/forms

From: "Andrew J(dot) Kopciuch" <akopciuch(at)bddf(dot)ca>
To: Bruce Young <hbrucey(at)yahoo(dot)com>, pgsql-php(at)postgresql(dot)org
Subject: Re: DESIGN CONCEPT (performance) - switch/arrays/forms
Date: 2003-05-31 04:58:48
Message-ID: 200305302258.48716.akopciuch@bddf.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Why not just store the types in the DB and query that?

-- table definition

create table categories
(
type whateverTypeThisFieldActuallyIs (ie int) primary key,
name text,
form text
);

// PHP code

$type = $HTTP_GET_VARS['type'];

$rv = pg_exec($dbConnection,
"SELECT form FROM categories WHERE type = '$type';");

if (pg_numrows($rv) > 0)
{
list($form) = pg_fetch_row($rv, 0);
include($form);
}
else
{
show_error("Item Type not found", $type);
}

No arrays ... no loops. One simple IF. Should do what you need.

I have worked on sites where the entire content is stored in the database ...
works fine. Pefectly fast.

Have you looked into PHP cache extensions if speed is an issue for file
parsing? try: http://www.php-accelerator.co.uk/

In response to

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Bruce Young 2003-05-31 06:00:24 Re: DESIGN CONCEPT (performance) - switch/arrays/forms
Previous Message brew 2003-05-31 03:36:44 Re: DESIGN CONCEPT (performance) - switch/arrays/forms