Queries and server usage.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Queries and server usage.

Post by Mightywayne »

Hmm, been a long time since I've been here. Anyhoo.

I was wondering, when is a query actually counted as being done? I'll just give my example.

Code: Select all

$example = mysql_query("SELECT example FROM example");

// or does it actually get done when called upon? Such as...

if ($example = $example)
{echo "Blah blah."};
Also, I'm wondering if you think having a query on every page the user goes to is bad. Because I want to have custom layouts for folks, and it'll find what layout they've selected, and select the correct .css file.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The query is performed immediately under normal circumstances.

A database query per page is a relatively light load as far as I'm concerned. However their preferences could be stored into a session variable to cache the information so you don't need to query.
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post by Mightywayne »

Cool, thanks.

(normal circumstances DOES mean when the variable sets it to it, right?)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

"Normal circumstances" means where the query isn't set up to perform in a delayed fashion.
Post Reply