|
Posted by Jerry Stuckle on 11/23/06 22:29
Sandman wrote:
> In article <EfydnUyi9uhnBvjYnZ2dnUVZ_u-dnZ2d@comcast.com>,
> Jerry Stuckle <jstucklex@attglobal.net> wrote:
>
>
>><snip>
>>
>>>## index.php
>>> require_once("member.php");
>>> print member_name(12);
>>>
>>>## member.php
>>> $q=mysql_query("select id, name, label from members");
>>> while ($r=mysql_fetch_assoc($q)){
>>> $GLOBALS["members"][$r["id"]] = $r;
>>> }
>>>
>>> function member_name($id){
>>> $m = $GLOBALS["members"][$id];
>>> $online = in_array($id, $GLOBALS["surfers"]) ? "on" : "off";
>>> return icon("online/$online") . " $m[name] $m[label]";
>>> }
>>>
>>>##
>>
>><snip>
>>
>>Looks like you need as SQL database.
>>
>>You may have to change your logic a little - I don't know enough of the
>>detaisl. But it's the right way to go.
>>
>>You can implement a small, lightly loaded site like this in flat files,
>>as you're doing. But there comes a time where that is no longer
>>feasible, and it's time to start using a database of some sort - that's
>>what they were made for. And a SQL RDB makes a lot of sense.
>
>
> Eh? I *AM* using MySQL. As shown in my code above. Using MySQL for
> this takes too long.
>
>
OK, I thought you were saying the information you're after was not on
the database. My misunderstand.
What's "too slow"? 1 second? 10 seconds? 100 seconds? How many rows
are you talking about?
Sure, you can implement this in flat files. But it's going to take
longer to search your flat files in PHP than MySQL does in compiled
code. The same is pretty much true for searching an array in PHP -
small arrays are faster, but as the array grows, the difference becomes
less.
You'd be much better off optimizing your database (and the database
design, if necessary), and potentially your queries. I can't see why it
should take all those queries to get the info you want.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|