Commits

Your PHP Pro committed b508413

Changes to queries to increase speed.

Comments (0)

Files changed (1)

 <?php
 /*
 ##############################################################################
-# PHP Scratch And Win                                           Version 4.03 #
+# PHP Scratch And Win                                           Version 4.04 #
 # Copyright 2012                                          www.YourPHPPro.com #
 #                                                                            #
 # For questions concerning licensing, please read license.txt                #
 	if (CONSTANT("phpScratchAndWin_Debug")=="1") {
 		print "<!-- Start Checking for Prizes -->\n";
 	}
-	$Query = "SELECT Count(*) AS Count FROM Prizes WHERE Prize_Credits>0 AND Prize_Active='Yes'";
+	$Query = "SELECT Count(*) AS Count FROM Prizes WHERE Prize_Credits>0 AND Prize_Active='Yes';";
 	$PrizeAvailable = CCGetDBValue($Query, $DBConnection);
 	if ($PrizeAvailable<1) {
 		if (CONSTANT("phpScratchAndWin_Debug")=="1") {
 
 	// Generate a Ticket Serial Number
 	$Ticket_SerialNumber = Custom_GenerateTicketSerial();
-	$Query = "INSERT INTO Tickets (Ticket_Email_Address, Ticket_IPAddress, Ticket_SerialNumber, Ticket_DrawDate, Ticket_Number_1, Ticket_Number_2, Ticket_Pick_1, Ticket_Pick_2, Ticket_Pick_3, Ticket_Pick_4, Ticket_Show_1, Ticket_Show_2, Ticket_Show_3, Ticket_Show_4, Ticket_Played, Ticket_Winner) VALUES ('" . $Email_Address . "', INET_ATON('" . $_SERVER["REMOTE_ADDR"] . "'), '" . $Ticket_SerialNumber . "', NOW( ) , '" . $Number_1 . "', '" . $Number_2 . "', '" . $Pick_1 . "', '" . $Pick_2 . "', '" . $Pick_3 . "', '" . $Pick_4 . "', 'No', 'No', 'No', 'No', 'No', '" . $Winning_Ticket . "')";
+	$Query = "INSERT INTO Tickets (Ticket_Email_Address, Ticket_IPAddress, Ticket_SerialNumber, Ticket_DrawDate, Ticket_Number_1, Ticket_Number_2, Ticket_Pick_1, Ticket_Pick_2, Ticket_Pick_3, Ticket_Pick_4, Ticket_Show_1, Ticket_Show_2, Ticket_Show_3, Ticket_Show_4, Ticket_Played, Ticket_Winner) VALUES ('" . $Email_Address . "', INET_ATON('" . $_SERVER["REMOTE_ADDR"] . "'), '" . $Ticket_SerialNumber . "', NOW( ) , '" . $Number_1 . "', '" . $Number_2 . "', '" . $Pick_1 . "', '" . $Pick_2 . "', '" . $Pick_3 . "', '" . $Pick_4 . "', 'No', 'No', 'No', 'No', 'No', '" . $Winning_Ticket . "');";
 	$DBConnection->query($Query);
 	if (CONSTANT("phpScratchAndWin_Debug")=="1") {
 		print "<!-- Completed Inserting New Record - Ticket Serial# [" . $Ticket_SerialNumber . "].  -->\n";
 		print "<!-- Checking Views in PlayTicket [" . $Ticket_SerialNumber . "] -->\n";
 	}
 	if ($View=="1") {
-		$Query = "UPDATE Tickets SET Ticket_Show_1='Yes' where Ticket_ID='" . $TicketRecord["Ticket_ID"] . "' LIMIT 1";
+		$Query = "UPDATE Tickets SET Ticket_Show_1='Yes' where Ticket_ID='" . $TicketRecord["Ticket_ID"] . "';";
 		$DBConnection->query($Query);
 		$TicketRecord["Ticket_Show_1"]="Yes";
 		if (CONSTANT("phpScratchAndWin_Debug")=="1") {
 		}
 	}
 	if ($View=="2") {
-		$Query = "UPDATE Tickets SET Ticket_Show_2='Yes' where Ticket_ID='" . $TicketRecord["Ticket_ID"] . "' LIMIT 1";
+		$Query = "UPDATE Tickets SET Ticket_Show_2='Yes' where Ticket_ID='" . $TicketRecord["Ticket_ID"] . "';";
 		$DBConnection->query($Query);
 		$TicketRecord["Ticket_Show_2"]="Yes";
 		if (CONSTANT("phpScratchAndWin_Debug")=="1") {
 		}
 	}
 	if ($View=="3") {
-		$Query = "UPDATE Tickets SET Ticket_Show_3='Yes' where Ticket_ID='" . $TicketRecord["Ticket_ID"] . "' LIMIT 1";
+		$Query = "UPDATE Tickets SET Ticket_Show_3='Yes' where Ticket_ID='" . $TicketRecord["Ticket_ID"] . "';";
 		$DBConnection->query($Query);
 		$TicketRecord["Ticket_Show_3"]="Yes";
 		if (CONSTANT("phpScratchAndWin_Debug")=="1") {
 		}
 	}
 	if ($View=="4") {
-		$Query = "UPDATE Tickets SET Ticket_Show_4='Yes' where Ticket_ID='" . $TicketRecord["Ticket_ID"] . "' LIMIT 1";
+		$Query = "UPDATE Tickets SET Ticket_Show_4='Yes' where Ticket_ID='" . $TicketRecord["Ticket_ID"] . "';";
 		$DBConnection->query($Query);
 		$TicketRecord["Ticket_Show_4"]="Yes";
 		if (CONSTANT("phpScratchAndWin_Debug")=="1") {
 					print "<!-- Query: " . $Query . " -->\n";
 				}
 				unset($Query);
-				$Query = "UPDATE Prizes SET Prize_Credits=Prize_Credits-1 WHERE Prize_ID='" . $PrizeRecord["Prize_ID"] . "' LIMIT 1;";
+				$Query = "UPDATE Prizes SET Prize_Credits=Prize_Credits-1 WHERE Prize_ID='" . $PrizeRecord["Prize_ID"] . "';";
 				$DBConnection->query($Query);
 				if (CONSTANT("phpScratchAndWin_Debug")=="1") {
 					print "<!-- Removing 1 credit from Prize [" . $PrizeRecord["Prize_DisplayName"] . "] -->\n";
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.