|
Posted by Jim Carlock on 01/25/07 00:53
> "FFMG" <spambuc...@myoddweb.com> wrote:
: In my site I have a config table, (MySQL), with about 30 entries;
: the data is loaded on every single page load. This is not the only
: call to the db, (we do a total of about 8 calls to the db).
:
: As with many configurations settings, once the options are set
: the values will not change much.
Jim Carlock replied...
:: Use an include file that holds a function that returns the data inside
:: an array. This works well for textual and numeric data.
::
:: <?php
:: require("data.php")
:: ?>
::
:: <data.php>
:: function GetMyArray() { return(array("data1", "data2", 1, 2, 3, 4)); }
:: </data.php>
::
"FFMG" asked...
: Sorry I am not sure I follow, what is that code for?
:
: How does it answer my OP?
A data file holds information. An array typically gets created to
hold text and numbers and it loads super fast. You mentioned
30(?) items, and that seems trivial for the most part (unless each item
ends up of massive size). My response presented an alternative
way to look at it the problem. You stated you tried the the "flat file"
alternative.
If it's the programmer that only does the updates, it's rather easy to
update the included file's array contents. You could also write that
array to disk (I'm thinking along the lines of text and numbers as
opposed to binary data... I haven't messed with trying to put binary
contents into an array).
It sounded like you have a common file that gets loaded up by a lot
of pages, that doesn't get updated often.
Under those conditions, using require() or include() seems like a
natural choice (it requires much more thought though if you've
got multiple users that update things concurrently, so in that case
a DBMS is probably the best thing to stick with).
The question you asked, "Flat file, did I waste my time?" comes
across as one of those goofy subjective questions, like "Did I
waste my time getting married?" It's a rather personal question
that only you can answer yourself. I can not argue that one way
or the other, it's 100% your question! And either YOU answer it,
"I wasted my time!", or you state, "I learned something, so while
I spent some time on it, all is well and I'll get over it". Those may
or may not be the only answers (some folks create really goofy
answers to such ponderings) and noone but you can answer that
question.
It's not a good idea to ask anyone else if "YOU" wasted your
time. How can anyone else know without you specifically telling
them that you wasted your time?
--
Jim Carlock
Post replies to the group.
Navigation:
[Reply to this message]
|