refactor: s1_vdata queries cached and reused

#313
This commit is contained in:
Martin Ambrus
2017-11-20 10:10:29 +01:00
parent 0984c7ef34
commit 645793dde2
12 changed files with 548 additions and 388 deletions
+2 -2
View File
@@ -49,8 +49,8 @@ if($_GET['uid'])
<td>Villages:</td>
<td>
<?php
$result = mysqli_query($GLOBALS["link"], "SELECT SQL_CACHE * FROM ".TB_PREFIX."vdata WHERE owner = ".(int) $user['id']."");
$num_rows = mysqli_num_rows($result);
$result = mysqli_query($GLOBALS["link"], "SELECT Count(*) as Total FROM ".TB_PREFIX."vdata WHERE owner = ".(int) $user['id']."");
$num_rows = mysqli_fetch_array($result, MYSQLI_ASSOC)['Total'];
echo $num_rows;
?>
</td>
+4 -3
View File
@@ -51,9 +51,10 @@ $users = mysqli_num_rows(mysqli_query($GLOBALS["link"], "SELECT SQL_CACHE * FROM
<tr>
<td>Villages settled</td>
<td><?php
$result = mysqli_query($GLOBALS["link"], "SELECT SQL_CACHE * FROM ".TB_PREFIX."vdata");
$num_rows = mysqli_num_rows($result);
echo $num_rows; ?>
$result = mysqli_query($GLOBALS["link"], "SELECT Count(*) as Total FROM ".TB_PREFIX."vdata");
$num_rows = mysqli_fetch_array($result, MYSQLI_ASSOC)['Total'];
echo $num_rows;
?>
</td>
</tr>
</tbody>