X-Original-To: pgsql-php@postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id D912B925F87 for ; Sat, 31 May 2003 02:00:36 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 96261-05 for ; Sat, 31 May 2003 02:00:26 -0400 (EDT) Received: from web10408.mail.yahoo.com (web10408.mail.yahoo.com [216.136.130.110]) by developer.postgresql.org (Postfix) with SMTP id C1F84925F82 for ; Sat, 31 May 2003 02:00:25 -0400 (EDT) Message-ID: <20030531060024.19400.qmail@web10408.mail.yahoo.com> Received: from [69.22.37.171] by web10408.mail.yahoo.com via HTTP; Fri, 30 May 2003 23:00:24 PDT Date: Fri, 30 May 2003 23:00:24 -0700 (PDT) From: Bruce Young Subject: Re: DESIGN CONCEPT (performance) - switch/arrays/forms To: pgsql-php@postgresql.org In-Reply-To: <200305302258.48716.akopciuch@bddf.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/58 X-Sequence-Number: 2063 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" 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