[prev in list] [next in list] [prev in thread] [next in thread]
List: freetrade-cvs
Subject: CVS update: freetrade2/modules/database/mysql coupon
From: FreeTrade CVS Development <jon () clearink ! com>
Date: 2000-05-27 16:19:34
[Download RAW message or body]
User: dilinger
Date: 00/05/27 09:19:34
Modified: modules/database/mysql coupon
Log:
Added getCouponByID(), for screen/edit_coupon.
Revision Changes Path
1.3 +89 -38 freetrade2/modules/database/mysql/coupon
Index: coupon
===================================================================
RCS file: /products/cvs/freetrade/freetrade2/modules/database/mysql/coupon,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- coupon 2000/05/27 15:49:35 1.2
+++ coupon 2000/05/27 16:19:33 1.3
@@ -2,13 +2,16 @@
/*
** File: coupon
** Description: functions for dealing with coupons
- ** Version: $Revision: 1.2 $
+ ** Version: $Revision: 1.3 $
** Created: 11/4/1999
** Author: Leon Atkinson
** Email: leon@clearink.com
** CVS Author: $Author: dilinger $
- ** Last Revised: $Date: 2000/05/27 15:49:35 $
+ ** Last Revised: $Date: 2000/05/27 16:19:33 $
** Log : $Log: coupon,v $
+ ** Log : Revision 1.3 2000/05/27 16:19:33 dilinger
+ ** Log : Added getCouponByID(), for screen/edit_coupon.
+ ** Log :
** Log : Revision 1.2 2000/05/27 15:49:35 dilinger
** Log : Added getCouponList(), for grabbing all tuples in coupon table.
** Log :
@@ -351,49 +354,97 @@
}
+ /*
+ ** Return a hashmap of all coupons in the db (and the number of rows).
+ */
+ function getCouponList()
+ {
+ global $DatabaseLink;
+ gloval $continueScript;
- /*
- ** Return a hashmap of all coupons in the db (and the number of rows).
- */
- function getCouponList($list, $invoice)
- {
- global $DatabaseLink;
- gloval $continueScript;
-
- $Query = "SELECT ID, Name, DollarOff, PercentageOff, MinAmountPurchased, ";
- $Query .= "DATE_FORMAT(StartDate, '%Y/%m/%d'), DATE_FORMAT(EndDate, '%Y/%m/%d'), ";
- $Query .= "NeverExpires, Combineable, DisplayPrecedence ";
- $Query .= "FROM coupon ";
- $Query .= "ORDER BY DisplayPrecedence, Name ";
-
- if ( !($DatabaseResult = mysql_query($Query, $DatabaseLink)) )
- {
- print("<!-- " . mysql_errno() . ": " . mysql_error() .
- " Query was $Query -->\n");
- $continueScript = FALSE;
- }
- else
- {
- while($DatabaseRow = mysql_fetch_row($DatabaseResult))
- {
- $coupons["ID"][] = $DatabaseRow[0];
- $coupons["Name"][] = $DatabaseRow[1];
- $coupons["DollarOff"][] = $DatabaseRow[2];
- $coupons["PercentageOff"][] = $DatabaseRow[3];
- $coupons["MinAmountPurchased"][] = $DatabaseRow[4];
- $coupons["StartDate"][] = $DatabaseRow[5];
- $coupons["EndDate"][] = $DatabaseRow[6];
- $coupons["NeverExpires"][] = $DatabaseRow[7];
- $coupons["Combineable"][] = $DatabaseRow[8];
- $coupons["DisplayPrecedence"][] = $DatabaseRow[9];
+ $Query = "SELECT ID, Name, DollarOff, PercentageOff, MinAmountPurchased, ";
+ $Query .= "DATE_FORMAT(StartDate, '%Y/%m/%d'), DATE_FORMAT(EndDate, '%Y/%m/%d'), ";
+ $Query .= "NeverExpires, Combineable, DisplayPrecedence ";
+ $Query .= "FROM coupon ";
+ $Query .= "ORDER BY DisplayPrecedence, Name ";
+
+ if ( !($DatabaseResult = mysql_query($Query, $DatabaseLink)) )
+ {
+ print("<!-- " . mysql_errno() . ": " . mysql_error() .
+ " Query was $Query -->\n");
+ $continueScript = FALSE;
+ }
+ else
+ {
+ while($DatabaseRow = mysql_fetch_row($DatabaseResult))
+ {
+ $coupons["ID"][] = $DatabaseRow[0];
+ $coupons["Name"][] = $DatabaseRow[1];
+ $coupons["DollarOff"][] = $DatabaseRow[2];
+ $coupons["PercentageOff"][] = $DatabaseRow[3];
+ $coupons["MinAmountPurchased"][] = $DatabaseRow[4];
+ $coupons["StartDate"][] = $DatabaseRow[5];
+ $coupons["EndDate"][] = $DatabaseRow[6];
+ $coupons["NeverExpires"][] = $DatabaseRow[7];
+ $coupons["Combineable"][] = $DatabaseRow[8];
+ $coupons["DisplayPrecedence"][] = $DatabaseRow[9];
- }
- }
+ }
+ }
// So caller knows how many rows to traverse
$coupons["NumRows"] = mysql_num_rows($DatabaseResult);
return $coupons;
}
+
+
+
+ /*
+ ** Given a coupon ID, find it and return it's tuple.
+ */
+ function findCouponByID($id)
+ {
+ global $DatabaseLink;
+ gloval $continueScript;
+
+ $Query = "SELECT ID, Name, DollarOff, PercentageOff, ";
+ $Query .= "MinAmountPurchased, StartDate, EndDate, NeverExpires, ";
+ $Query .= "Combineable, DisplayPrecedence ";
+ $Query .= "FROM coupon ";
+ $Query .= "WHERE ID = '" . $id . "'";
+
+ if ( !($DatabaseResult = mysql_query($Query, $DatabaseLink)) )
+ {
+ print("<!-- " . mysql_errno() . ": " . mysql_error() .
+ " Query was $Query -->\n");
+ $continueScript = FALSE;
+ }
+ else
+ {
+ $DatabaseRow = mysql_fetch_row($DatabaseResult);
+
+ $result["ID"] = $DatabaseRow[0];
+ $result["Name"] = $DatabaseRow[1];
+ $result["DollarOff"] = $DatabaseRow[2];
+ $result["PercentageOff"] = $DatabaseRow[3];
+ $result["MinAmountPurchased"] = $DatabaseRow[4];
+ $result["StartDate"] = $DatabaseRow[5];
+ $result["EndDate"] = $DatabaseRow[6];
+ $result["NeverExpires"] = $DatabaseRow[7];
+ $result["Combineable"] = $DatabaseRow[8];
+ $result["DisplayPrecedence"] = $DatabaseRow[9];
+ if ($result["EndDate"] == 0)
+ {
+ $result["EndDate"] = $result["StartDate"];
+ }
+ }
+
+ $return $result;
+ }
+
+
+
+
?>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic