From e21571f342cda9dc4b7709287202ed2b33c7be92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20Fr=C3=B6hlich?= Date: Thu, 4 Aug 2011 23:58:09 +0200 Subject: Simplified unneccesary complex SQL queries --- includes/wot.inc.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'includes/wot.inc.php') diff --git a/includes/wot.inc.php b/includes/wot.inc.php index e8b0448..68e15d5 100644 --- a/includes/wot.inc.php +++ b/includes/wot.inc.php @@ -34,9 +34,8 @@ function get_number_of_assurances ($userid) { - $res = query_init ("SELECT `users`. *, count(*) AS `list` FROM `users`, `notary` - WHERE `users`.`id` = `notary`.`from` AND `notary`.`from` != `notary`.`to` AND `from`='".intval($userid)."' - GROUP BY `notary`.`from`"); + $res = query_init ("SELECT count(*) AS `list` FROM `notary` + WHERE `notary`.`from` != `notary`.`to` AND `notary`.`from`='".intval($userid)."'"); $row = query_getnextrow($res); return intval($row['list']); @@ -44,9 +43,8 @@ function get_number_of_assurees ($userid) { - $res = query_init ("SELECT `users`. *, count(*) AS `list` FROM `users`, `notary` - WHERE `users`.`id` = `notary`.`to` AND `notary`.`from` != `notary`.`to` AND `to`='".intval($userid)."' - GROUP BY `notary`.`to`"); + $res = query_init ("SELECT count(*) AS `list` FROM `notary` + WHERE `notary`.`from` != `notary`.`to` AND `notary`.`to`='".intval($userid)."'"); $row = query_getnextrow($res); return intval($row['list']); @@ -54,16 +52,14 @@ function get_top_assurer_position ($no_of_assurances) { - $res = query_init ("SELECT count(*) AS `list` FROM `users` - inner join `notary` on `users`.`id` = `notary`.`from` + $res = query_init ("SELECT count(*) AS `list` FROM `notary` GROUP BY `notary`.`from` HAVING count(*) > '".intval($no_of_assurances)."'"); return intval(query_get_number_of_rows($res)+1); } function get_top_assuree_position ($no_of_assurees) { - $res = query_init ("SELECT count(*) AS `list` FROM `users` - inner join `notary` on `users`.`id` = `notary`.`to` + $res = query_init ("SELECT count(*) AS `list` FROM `notary` GROUP BY `notary`.`to` HAVING count(*) > '".intval($no_of_assurees)."'"); return intval(query_get_number_of_rows($res)+1); } -- cgit v1.2.1 From c0afd35630115a7e186b912d2404f2c34f1f18b3 Mon Sep 17 00:00:00 2001 From: Bernhard Froehlich Date: Sat, 6 Aug 2011 20:56:38 +0200 Subject: Qualified columns in some statements --- includes/wot.inc.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'includes/wot.inc.php') diff --git a/includes/wot.inc.php b/includes/wot.inc.php index 68e15d5..ce35ed6 100644 --- a/includes/wot.inc.php +++ b/includes/wot.inc.php @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ +*/ function query_init ($query) { @@ -66,25 +66,25 @@ function get_given_assurances ($userid) { - $res = query_init ("select * from `notary` where `from`='".intval($userid)."' and `from` != `to` order by `id` asc"); + $res = query_init ("select * from `notary` where `notary`.`from`='".intval($userid)."' and `notary`.`from` != `to` order by `notary`.`id` asc"); return $res; } function get_received_assurances ($userid) { - $res = query_init ("select * from `notary` where `to`='".intval($userid)."' and `from` != `to` order by `id` asc "); + $res = query_init ("select * from `notary` where `notary`.`to`='".intval($userid)."' and `notary`.`from` != `notary`.`to` order by `notary`.`id` asc "); return $res; } function get_given_assurances_summary ($userid) { - $res = query_init ("select count(*) as number,points,awarded,method from notary where `from`='".intval($userid)."' group by points,awarded,method"); + $res = query_init ("select count(*) as number,points,awarded,method from notary where `notary`.`from`='".intval($userid)."' group by points,awarded,method"); return $res; } - + function get_received_assurances_summary ($userid) { - $res = query_init ("select count(*) as number,points,awarded,method from notary where `to`='".intval($userid)."' group by points,awarded,method"); + $res = query_init ("select count(*) as number,points,awarded,method from notary where `notary`.`to`='".intval($userid)."' group by points,awarded,method"); return $res; } @@ -124,7 +124,7 @@ $awarded = 100; } else - $experience = 0; + $experience = 0; switch ($row['method']) { @@ -291,7 +291,7 @@ $res = get_given_assurances(intval($userid)); while($row = mysql_fetch_assoc($res)) { - $fromuser = get_user (intval($row['to'])); + $fromuser = get_user (intval($row['to'])); calc_experience ($row,$points,$experience,$sum_experience); $name = show_user_link ($fromuser['fname']." ".$fromuser['lname'],intval($row['to'])); output_assurances_row (intval($row['id']),$row['date'],$name,intval($row['awarded']),$row['location'],$row['method']==""?"":_(sprintf("%s", $row['method'])),$experience); -- cgit v1.2.1 From 84c058819acda629c4d3f88350d0cb5f3f24fd38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20Fr=C3=B6hlich?= Date: Tue, 16 Aug 2011 23:53:27 +0200 Subject: Patches for bugs noticed by Hans. --- includes/wot.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'includes/wot.inc.php') diff --git a/includes/wot.inc.php b/includes/wot.inc.php index ce35ed6..ff9a0a3 100644 --- a/includes/wot.inc.php +++ b/includes/wot.inc.php @@ -412,7 +412,7 @@ else { $sum_points_countable = $sum_points; - $remark_points = " "; + $remark_points = " "; } if ($sum_experience > $max_experience) { @@ -439,7 +439,7 @@ if ($sum_points_countable < $max_points) { if ($sum_experience_countable != 0) - $remark_experience = $points_on_hold_txt;_("Points on hold due to less assurance points"); + $remark_experience = _("Points on hold due to less assurance points"); $sum_experience_countable = 0; if ($sum_experience_other_countable != 0) $remark_experience_other = _("Points on hold due to less assurance points"); -- cgit v1.2.1