我一直在编写一个新仪表板,我想在其中显示各种数据库统计信息,主要是计算行数并将结果设置为变量,它们都可以正常工作,但我有点担心如果有这么多 SELECT 查询可能会变得太重很多用户正在进入或刷新页面。
感谢您的意见:)
$tbl_players = players;
$xbox = mysql_query("SELECT * FROM $tbl_players WHERE Console = 'XBOX360'");
$ps3 = mysql_query("SELECT * FROM $tbl_players WHERE Console = 'PS3'");
$pc = mysql_query("SELECT * FROM $tbl_players WHERE Console = 'PC'");
$xbfa = mysql_query("SELECT * FROM $tbl_players WHERE Console = 'XBOX360' && fathread LIKE 'http%'");
$psfa = mysql_query("SELECT * FROM $tbl_players WHERE Console = 'PS3' && fathread LIKE 'http%'");
$pfa = mysql_query("SELECT * FROM $tbl_players WHERE Console = 'PC' && fathread LIKE 'http%'");
$xbcr = mysql_query("SELECT * FROM $tbl_players WHERE Console = 'XBOX360' && crthread LIKE 'http%'");
$pscr = mysql_query("SELECT * FROM $tbl_players WHERE Console = 'PS3' && crthread LIKE 'http%'");
$pcr = mysql_query("SELECT * FROM $tbl_players WHERE Console = 'PC' && crthread LIKE 'http%'");
while($row = mysql_fetch_array($xbox))
{
$cxbox = mysql_num_rows($xbox);
}
while($row = mysql_fetch_array($ps3))
{
$cps3 = mysql_num_rows($ps3);
}
while($row = mysql_fetch_array($pc))
{
$cpc = mysql_num_rows($pc);
}
while($row = mysql_fetch_array($xbfa))
{
$xboxfa = mysql_num_rows($xbfa);
}
while($row = mysql_fetch_array($psfa))
{
$ps3fa = mysql_num_rows($psfa);
}
while($row = mysql_fetch_array($pfa))
{
$pcfa = mysql_num_rows($pfa);
}
while($row = mysql_fetch_array($xbcr))
{
$xboxcr = mysql_num_rows($xbcr);
}
while($row = mysql_fetch_array($pscr))
{
$ps3cr = mysql_num_rows($pscr);
}
while($row = mysql_fetch_array($pcr))
{
$pccr = mysql_num_rows($pcr);
}
$tbl_interactive = interactive;
$maximum = mysql_query("SELECT ID FROM $tbl_interactive ORDER BY ID DESC LIMIT 1");
while($max = mysql_fetch_array($maximum))
{
$cint = $max['ID'];
}
$xboxf = mysql_query("SELECT * FROM $tbl_interactive WHERE Console = 'XBOX360' && Type = 'Player' && $date < EndTime");
$xboxc = mysql_query("SELECT * FROM $tbl_interactive WHERE Console = 'XBOX360' && Type = 'Club' && $date < EndTime");
$ps3f = mysql_query("SELECT * FROM $tbl_interactive WHERE Console = 'PS3' && Type = 'Player' && $date < EndTime");
$ps3c = mysql_query("SELECT * FROM $tbl_interactive WHERE Console = 'PS3' && Type = 'Club' && $date < EndTime");
$pcf = mysql_query("SELECT * FROM $tbl_interactive WHERE Console = 'PC' && Type = 'Player' && $date < EndTime");
$pcc = mysql_query("SELECT * FROM $tbl_interactive WHERE Console = 'PC' && Type = 'Club' && $date < EndTime");
while($row = mysql_fetch_array($xboxf))
{
$xboxfi = mysql_num_rows($xboxf);
}
while($row = mysql_fetch_array($xboxc))
{
$xboxci = mysql_num_rows($xboxc);
}
while($row = mysql_fetch_array($ps3f))
{
$ps3fi = mysql_num_rows($ps3f);
}
while($row = mysql_fetch_array($ps3c))
{
$ps3ci = mysql_num_rows($ps3c);
}
while($row = mysql_fetch_array($pcf))
{
$pcfi = mysql_num_rows($pcf);
}
while($row = mysql_fetch_array($pcc))
{
$pcci = mysql_num_rows($pcc);
}
非常感谢!