pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Young <hbrucey@yahoo.com>
To: pgsql-php@postgresql.org
Subject: Re: DESIGN CONCEPT (performance) -  switch/arrays/forms
Date: Fri, 30 May 2003 23:00:24 -0700 (PDT)
Message-ID: <20030531060024.19400.qmail@web10408.mail.yahoo.com> (raw)
In-Reply-To: <200305302258.48716.akopciuch@bddf.ca>

I dont know why i was thinking about solving the problem with arrays.  i came
up with the same solution and was about to post it.  thanks a lot guys for the
advice, or any more.  : )

$query = "select * from test.category where id=$type";
$result = pg_query ($dbconnect, $query);

if (pg_num_rows($result))
{
	$row = pg_fetch_array($result);
	include $row['form'];
} else {
	show_error("Item Type not found",1);
}





--- "Andrew J. Kopciuch" <akopciuch@bddf.ca> wrote:
> 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/
> 


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com



view thread (4+ messages)

Message-ID: <20030531060024.19400.qmail@web10408.mail.yahoo.com>
Permalink:  ../20030531060024.19400.qmail@web10408.mail.yahoo.com/
Also on:    postgresql.org/message-id/20030531060024.19400.qmail@web10408.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: hbrucey@yahoo.com
  Subject: Re: DESIGN CONCEPT (performance) -  switch/arrays/forms
  In-Reply-To: <20030531060024.19400.qmail@web10408.mail.yahoo.com>
  References: <200305302258.48716.akopciuch@bddf.ca> <20030531060024.19400.qmail@web10408.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox