Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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);
	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:

In response to


pgsql-php by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group