summaryrefslogtreecommitdiff
path: root/common/tables/dividend_credits.php
diff options
context:
space:
mode:
authorKyle McFarland <tfkyle@gmail.com>2018-01-31 00:51:07 -0600
committerKyle McFarland <tfkyle@gmail.com>2018-01-31 00:51:07 -0600
commit61d1aa04d8d44b17bfe6dace90088669fc6c3df8 (patch)
tree7ede15c880e4c41a18cded46fe6d03fb2dc4543b /common/tables/dividend_credits.php
downloadmcoop-61d1aa04d8d44b17bfe6dace90088669fc6c3df8.zip
mcoop-61d1aa04d8d44b17bfe6dace90088669fc6c3df8.tar.gz
mcoop-61d1aa04d8d44b17bfe6dace90088669fc6c3df8.tar.bz2
Initial importHEADmaster
* Registration system's almost done * Just part way through implementing tasks So not much done yet, but it's a start.
Diffstat (limited to 'common/tables/dividend_credits.php')
-rw-r--r--common/tables/dividend_credits.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/common/tables/dividend_credits.php b/common/tables/dividend_credits.php
new file mode 100644
index 0000000..2f80ec0
--- /dev/null
+++ b/common/tables/dividend_credits.php
@@ -0,0 +1,36 @@
+<?php
+namespace mcoop;
+require_once("common/db_classes.php");
+
+class DividendCreditsUpgrader extends BaseIncrementalTableUpgrader {
+ function from_1_to_2() {
+ //$this->conn->exec("ALTER TABLE dividend_ ADD COLUMN (test BOOL)");
+ // No actual changes in this one, it was just to make sure the upgrader paths were working
+ }
+
+ function __construct($conn) {
+ $this->conn = $conn;
+ $this->table_name = "dividend_credits";
+ //$this->upgrade_method_names[2] = "from_1_to_2";
+ }
+}
+
+$dividend_credits_table_decl = new SimpleTableDecl(
+ "dividend_credits",
+ array(
+ "dividend_credits_ensure" => "INSERT IGNORE INTO dividend_credits (userid, year, credits, last_updated_table_version) VALUES (:userid, :year, 0, :table_ver)",
+ "add_to_dividend_credits" => "UPDATE dividend_credits SET credits=credits + :amount WHERE userid=:userid AND year=:year",
+ "remove_from_dividend_credits" => "UPDATE dividend_credits SET credits=credits - :amount WHERE userid=:userid AND year=:year",
+ "set_dividend_credits" => "UPDATE dividend_credits SET credits=:amount WHERE userid=:userid AND year=:year"
+ ),
+ "CREATE TABLE `dividend_credits` (
+`userid` INT NOT NULL,
+`year` INT NOT NULL,
+`credits` BIGINT NOT NULL,
+`last_updated_table_version` INT NOT NULL,
+PRIMARY KEY (`userid`, `year`)
+);",
+ 1,
+ "\mcoop\DividendCreditsUpgrader"
+);
+