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: 200305302258.48716.akopciuch@bddf.ca (view raw or flat)
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

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-2014 The PostgreSQL Global Development Group