Re: DESIGN CONCEPT (performance) - switch/arrays/forms - Mailing list pgsql-php

From Bruce Young
Subject Re: DESIGN CONCEPT (performance) - switch/arrays/forms
Date
Msg-id 20030531060024.19400.qmail@web10408.mail.yahoo.com
Whole thread Raw
In response to Re: DESIGN CONCEPT (performance) - switch/arrays/forms  ("Andrew J. Kopciuch" <akopciuch@bddf.ca>)
List pgsql-php
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

pgsql-php by date:

Previous
From: "Andrew J. Kopciuch"
Date:
Subject: Re: DESIGN CONCEPT (performance) - switch/arrays/forms
Next
From: pknoob
Date:
Subject: Inheritance issues displaying tables