using mysql to handle your tables is *way* faster than letting php handle it.
That's what it was made for, speed...!
In your case, you could just do a complex join I think. That would give all results in one table, and you could just order that on scheduletime, and voila, you'd have a pretty nice outcome, namely the schedule you were making via a complex way ;)
David T-G wrote:
Hi, all -- I'm so far about knee-deep in my project where I'll be using php to talk to the mysql database and spit out my web pages. I wonder if I should be making individual calls to the database or loading a table into an array so that I can walk it without those calls.For instance, I have an instructors table, a clients table, and a schedule table that has an instructor number column, a client number column, and a time slot column. In order to print an instructor's schedule for the day, I have to query the instructors table to get the id where the name matches, and then query the schedule table to get the clients and times where the time slot matches some time today, and then I have to repeatedly query the clients table to get the names where the returned id matches. Since the schedule should be arranged in time order, I might even have client 1 and then client 2 and then client 1 again -- but I've already switched to 2 so I have to start over for 1. It seems a bit silly to, say, load the entire clients table into an array because there could be thousands or millions of clients, but it's an awful pain to go and make all of those mysql_query calls to walk the clients list. Should I just build a huge query something like $query = "select fname,lname from clients where " ; foreach ($results_from_previous_query_somehow as $clinum) { $query .= "id = '$clinum' or "; } $query .= "id = ''" ; # nice always-failing value; easier than pruning and then query that way, to get all of what I need in one shot but not the whole table (unless I need it all)? Does sql like big OR clauses like that? I don't know if this is a PHP or a MySQL question, so this once I've posted it to both lists. I'll also summarize to both. TIA & HAND & Happy New Year :-D
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php