diff options
author | Bernhard Fröhlich <bernhard@cacert.org> | 2011-08-04 23:58:09 +0200 |
---|---|---|
committer | Bernhard Fröhlich <bernhard@cacert.org> | 2011-08-04 23:58:09 +0200 |
commit | e21571f342cda9dc4b7709287202ed2b33c7be92 (patch) | |
tree | baa9abbc6dbcf370c9b0bcc8b161aac629f41956 /includes/wot.inc.php | |
parent | d3b6033b790f7cbb7fbaa5f07f237b08ff28fe79 (diff) | |
download | cacert-devel-e21571f342cda9dc4b7709287202ed2b33c7be92.tar.gz cacert-devel-e21571f342cda9dc4b7709287202ed2b33c7be92.tar.xz cacert-devel-e21571f342cda9dc4b7709287202ed2b33c7be92.zip |
Simplified unneccesary complex SQL queries
Diffstat (limited to 'includes/wot.inc.php')
-rw-r--r-- | includes/wot.inc.php | 16 |
1 files changed, 6 insertions, 10 deletions
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); } |