Reply to Re: [PHP] Fastest templating mechanism

Your name:

Reply:


Posted by trlists on 10/21/93 11:15

On 8 May 2005 Evert | Rooftop Solutions wrote:

> What I really need is a fast lookup mechanism, to 'translate'
> statements.
>
> For example:
>
> setOutputType('xhtml');
> echo(translate('authorstart'));
>
> the function translate opens xhtml.data, which contains:
>
> authorstart : <span class="author">
> authorend : </span>
>
> so, the translate function looks 'authorstart' up and returns '<span
> class="author">'
>
> or if you had specified 'wml' as the outputtype, the file could like like:
>
> authorstart : <b>
> authorend : </b>
>
> and the function would return '<b>'
>
> This is all no problem, except that these lists can be pretty big. And I
> wouldn't like to load them all into the memory, or have to loop through
> the file every time translate is called.
>
> So I need a very fast mechanism to overcome this problem.

I think it's called a database. The fields are outputtype, key, and
text to output, with an index on outputtype + key, then you do
something like this:

select OutputText from TranslateTable where OutputType = 'wml'
and key = 'authorstart';

I wonder how many of these you really have. If on each script
invocation you will be looking up many of them (dozens or hundreds) it
might be more efficient to load all the ones for the outputtype you are
using into a PHP array at the start, whether that's in a hard-coded
array or loaded from the database. If you're only looking up a couple
then a separate database lookup for each one is probably more
efficient.

Incidentally I would say this is not a templating problem. It's simply
a translation or lookup problem.

--
Tom

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация