[thelist] php design question
rudy
r937 at interlog.com
Mon Nov 18 17:55:00 CST 2002
> $result = @mysql_query("SELECT * FROM menuitem WHERE menuitemID =
> '$id'");
> if(!$result)
> {
> echo(include('includes/db_error.php'));
> exit();
> }
> $row = mysql_fetch_array($result);
> $item = $row['item'];
> $description = $row['description'];
> $price = $row['price'];
> $categoryID = $row['categoryID'];
tom, i do exactly the same, only in coldfusion
my include would look like this
<cfquery name="menuitems" datasource="#dsrc#">
select iwould, listdesired, columnshere
, insteadof, selectstar
from menuitem
where menuitemID = #id#
</cfquery>
you're absolutely right that "there will be several pages where I pull the
menu item"
on my site, every page has a menu (except for old pages like aunt netty)
and i pull not just one menu item, but all of them
in my estimation, the results of my menu query should really hang around
for a while, which is how exactly how query results caching works --
coldfusion doesn't go back to the database, it just uses the query results
it got the last time, provided it's within a certain timespan
best example for this is state codes -- why would you want to query the
database more often than, say, daily? if a new state code has to be added,
the very latest your site will reflect that change is tomorrow (and i
daresay you will have have many days' notice, eh)
menu items to me are the same -- if i want to change the structure of my
site's menu, it won't show up for an hour, but in the meantime, my
performance is better because the server doesn't call the database...
... and this from a database guy!
also, in coldfusion, this caching is built in, all i have to do is add
cachedwithin="#CreateTimeSpan(0,1,0,0)#"
to the cfquery tag above
finally, the cfquery tag is brought in to every page with
<cfinclude template="menuitems.txt">
where i give the file name the same name as the query name used in the
cfquery tag
cfml (coldfusion markup language) is so like xhtml, it makes me shiver
rudy
More information about the thelist
mailing list