Odyssey
2019111900_AddProducts.php
1 <?php
2 /**
3  * Notes:
4  * 1. Anything complicated needs to be done with SQL.
5  * 2. Always have a check to know if the migration needs to occur (up or down).
6  * 3. Use up() and down(), not change(), because of the SQL
7  */
8 use Phinx\Migration\AbstractMigration;
9 
10 class AddProducts extends AbstractMigration {
11  public function up() {
12  $tableName = "cuprodlist";
13  $productList = array(
14  "HBBatch" => "Batch Home Banking",
15  "HBLive" => "Live Home Banking",
16  "UpgradeBL" => "Batch to Live HB Upgrade",
17  "Intuit" => "Intuit",
18  "SSL" => "SSL Hosting",
19  "SecForm" => "Secure Forms",
20  "Gold" => "Gold Package ",
21  "Platinum" => "Platinum Package ",
22  "Silver" => "Silver Package",
23  "ODYUP" => "Odyssey Upgrade",
24  "A2A" => "Account to Account EFT",
25  "M2M" => "Member to Member"
26  );
27  // Check for table
28  if ($this->hasTable($tableName)) {
29  foreach ($productList as $key => $value) {
30  // See if product already exists
31  $prodRow = $this->fetchRow("SELECT COUNT(*) as count FROM cuprodlist WHERE trim(home_cu_code) = '$key';");
32  // Add product if it doesn't exist
33  if ($prodRow['count'] == 0) {
34  $this->query("INSERT INTO $tableName (home_cu_code, home_cu_desc) VALUES ('$key', '$value')");
35  }
36  }
37  }
38  }
39 
40  public function down() {
41 
42  }
43 }