From: Bruce Young <hbrucey@yahoo.com>
To: pgsql-php@postgresql.org
Subject: DESIGN CONCEPT (performance) - switch/arrays/forms
Date: Fri, 30 May 2003 16:41:43 -0700 (PDT)
Message-ID: <20030530234143.2520.qmail@web10403.mail.yahoo.com> (raw)
Hi list!
i am working on a little project where i have a PHP script that selects a form
(located on hard drive)
using the switch statement and "include". for example:
switch ($type)
{
case 1:
include 'forms/add_edit/form_book.php';
break;
default:
show_error("Item Type not found",1);
}
i have about 5 scripts that use switch statement to select forms.
Problem is, right now i only have 1 category ($type). Now when i add about 10
or 20+ more categories, these scripts will start to become a pain to maintain
with all the switch/cases.
My idea is to have a category table with references to the forms on disk so i
can fetch it into an array; search the array to find the corresponding form for
the category id, and include that form;
example:
Category table
id | name | form
---+-------+---------------
1 | Book | form_book.php
--------------------------
$type = $HTTP_GET_VARS['type'];
# select id, form from categories;
# assign array values returned by query
# search if category exists ($type) and present error message
# present corresponding form to $type.
----------
My concern is, would this be too much work on the database and would it be
better to manually code it into the PHP script.
if this concept could work fine, could anyone give me an example on how to do
this? i am just learning PHP. thanks a lot.
- bruce
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
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: <20030530234143.2520.qmail@web10403.mail.yahoo.com>
References: <20030530234143.2520.qmail@web10403.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