Revision: 1350
http://mrbs.svn.sourceforge.net/mrbs/?rev=1350&view=rev
Author: cimorrison
Date: 2010-04-25 20:31:11 +0000 (Sun, 25 Apr 2010)
Log Message:
-----------
Added "LIMIT 1" where appropriate to SQL queries to improve performance.
Modified Paths:
--------------
mrbs/trunk/web/edit_entry.php
mrbs/trunk/web/edit_entry_handler.php
mrbs/trunk/web/month.php
mrbs/trunk/web/mrbs_sql.inc
mrbs/trunk/web/view_entry.php
mrbs/trunk/web/week.php
Modified: mrbs/trunk/web/edit_entry.php
===================================================================
--- mrbs/trunk/web/edit_entry.php 2010-04-22 21:29:27 UTC (rev 1349)
+++ mrbs/trunk/web/edit_entry.php 2010-04-25 20:31:11 UTC (rev 1350)
@@ -81,8 +81,11 @@
// If we had $id passed in then it's a modification.
if (isset($id))
{
- $sql = "select name, create_by, description, start_time, end_time,
- type, room_id, entry_type, repeat_id, private from $tbl_entry where
id=$id";
+ $sql = "SELECT name, create_by, description, start_time, end_time,
+ type, room_id, entry_type, repeat_id, private
+ FROM $tbl_entry
+ WHERE id=$id
+ LIMIT 1";
$res = sql_query($sql);
if (! $res)
@@ -140,7 +143,9 @@
if($entry_type >= 1)
{
$sql = "SELECT rep_type, start_time, end_date, rep_opt, rep_num_weeks
- FROM $tbl_repeat WHERE id=$rep_id";
+ FROM $tbl_repeat
+ WHERE id=$rep_id
+ LIMIT 1";
$res = sql_query($sql);
if (! $res)
Modified: mrbs/trunk/web/edit_entry_handler.php
===================================================================
--- mrbs/trunk/web/edit_entry_handler.php 2010-04-22 21:29:27 UTC (rev
1349)
+++ mrbs/trunk/web/edit_entry_handler.php 2010-04-25 20:31:11 UTC (rev
1350)
@@ -361,7 +361,7 @@
if (isset($id))
{
$ignore_id = $id;
- $repeat_id = sql_query1("SELECT repeat_id FROM $tbl_entry WHERE id=$id");
+ $repeat_id = sql_query1("SELECT repeat_id FROM $tbl_entry WHERE id=$id LIMIT
1");
if ($repeat_id < 0)
{
$repeat_id = 0;
Modified: mrbs/trunk/web/month.php
===================================================================
--- mrbs/trunk/web/month.php 2010-04-22 21:29:27 UTC (rev 1349)
+++ mrbs/trunk/web/month.php 2010-04-25 20:31:11 UTC (rev 1350)
@@ -130,10 +130,8 @@
// Get the area and room names (we will need them later for the heading)
$this_area_name = "";
$this_room_name = "";
-$this_area_name = htmlspecialchars(sql_query1("select area_name
- from $tbl_area where id=$area"));
-$this_room_name = htmlspecialchars(sql_query1("select room_name
- from $tbl_room where id=$room"));
+$this_area_name = htmlspecialchars(sql_query1("SELECT area_name FROM $tbl_area
WHERE id=$area LIMIT 1"));
+$this_room_name = htmlspecialchars(sql_query1("SELECT room_name FROM $tbl_room
WHERE id=$room LIMIT 1"));
$sql = "select id, area_name from $tbl_area order by area_name";
$res = sql_query($sql);
Modified: mrbs/trunk/web/mrbs_sql.inc
===================================================================
--- mrbs/trunk/web/mrbs_sql.inc 2010-04-22 21:29:27 UTC (rev 1349)
+++ mrbs/trunk/web/mrbs_sql.inc 2010-04-25 20:31:11 UTC (rev 1350)
@@ -149,7 +149,7 @@
{
global $tbl_entry, $tbl_repeat;
- $repeat_id = sql_query1("SELECT repeat_id FROM $tbl_entry WHERE id=$id");
+ $repeat_id = sql_query1("SELECT repeat_id FROM $tbl_entry WHERE id=$id LIMIT
1");
if ($repeat_id < 0)
{
return 0;
@@ -813,7 +813,7 @@
{
global $tbl_room;
- $id = sql_query1("SELECT area_id FROM $tbl_room WHERE (id = $id)");
+ $id = sql_query1("SELECT area_id FROM $tbl_room WHERE id=$id LIMIT 1");
if ($id <= 0)
{
$id = 0;
Modified: mrbs/trunk/web/view_entry.php
===================================================================
--- mrbs/trunk/web/view_entry.php 2010-04-22 21:29:27 UTC (rev 1349)
+++ mrbs/trunk/web/view_entry.php 2010-04-25 20:31:11 UTC (rev 1350)
@@ -266,7 +266,7 @@
if ($repeat_id != 0)
{
$res = sql_query("SELECT rep_type, end_date, rep_opt, rep_num_weeks
- FROM $tbl_repeat WHERE id=$repeat_id");
+ FROM $tbl_repeat WHERE id=$repeat_id LIMIT 1");
if (! $res)
{
fatal_error(0, sql_error());
Modified: mrbs/trunk/web/week.php
===================================================================
--- mrbs/trunk/web/week.php 2010-04-22 21:29:27 UTC (rev 1349)
+++ mrbs/trunk/web/week.php 2010-04-25 20:31:11 UTC (rev 1350)
@@ -123,10 +123,8 @@
// Get the area and room names (we will need them later for the heading)
$this_area_name = "";
$this_room_name = "";
-$this_area_name = htmlspecialchars(sql_query1("select area_name
- from $tbl_area where id=$area"));
-$this_room_name = htmlspecialchars(sql_query1("select room_name
- from $tbl_room where id=$room"));
+$this_area_name = htmlspecialchars(sql_query1("SELECT area_name FROM $tbl_area
WHERE id=$area LIMIT 1"));
+$this_room_name = htmlspecialchars(sql_query1("SELECT room_name FROM $tbl_room
WHERE id=$room LIMIT 1"));
$sql = "select id, area_name from $tbl_area order by area_name";
$res = sql_query($sql);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits