Optimization - functions.php

Bug #285519 reported by David Rubin on 2008-10-18
Affects Status Importance Assigned to Milestone
GPG Contact Form

Bug Description

I Just thought I would point out you can do all of the below that is commented out with a single query. It is not a great idea to do more quries then are nessary because it adds load to the db server(or local host) and running quries require a request to be made to an external application.

I have added a fix this. see below.

## User Settings
$query12 = mysql_query("SELECT username FROM user");
$username = mysql_result($query12, 0);

$query13 = mysql_query("SELECT password FROM user");
$password = mysql_result($query13, 0);

$query14 = mysql_query("SELECT lastlogin FROM user");
$lastlogin = mysql_result($query14, 0);

$query15 = mysql_query("SELECT lastip FROM user");
$lastip = mysql_result($query15, 0);
//The above was replaced by one single query. Less load on the server.
$query_user = mysql_query("SELECT password,username,lastip,lastlogin FROM user");
$result_user= mysql_fetch_assoc($query_user);
$username =$result_user['username'];
$password =$result_user['password'];
$lastip =$result_user['lastip'];

David Rubin (drubin) wrote :
Dr Small (drsmall) wrote :

Thanks for reporting this, drubin.
I have fixed the bug, and pushed the fix up to the development branch.

Changed in gpgcontact:
importance: Undecided → High
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers