Re: DESIGN CONCEPT (performance) - switch/arrays/forms

Поиск
Список
Период
Сортировка
От Andrew J. Kopciuch
Тема Re: DESIGN CONCEPT (performance) - switch/arrays/forms
Дата
Msg-id 200305302258.48716.akopciuch@bddf.ca
обсуждение исходный текст
Ответ на DESIGN CONCEPT (performance) - switch/arrays/forms  (Bruce Young <hbrucey@yahoo.com>)
Ответы Re: DESIGN CONCEPT (performance) - switch/arrays/forms  (Bruce Young <hbrucey@yahoo.com>)
Список 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/


В списке pgsql-php по дате отправления:

Предыдущее
От: brew@theMode.com
Дата:
Сообщение: Re: DESIGN CONCEPT (performance) - switch/arrays/forms
Следующее
От: Bruce Young
Дата:
Сообщение: Re: DESIGN CONCEPT (performance) - switch/arrays/forms