Odyssey
Public Member Functions | List of all members
AddCrossAccountsTable Class Reference
Inheritance diagram for AddCrossAccountsTable:

Public Member Functions

 up ()
 

Detailed Description

Definition at line 9 of file 2017121800_addcrossaccountstable.php.

Member Function Documentation

◆ up()

AddCrossAccountsTable::up ( )

Check for existence of file name

Table does not exist – CREATE

Definition at line 15 of file 2017121800_addcrossaccountstable.php.

15  {
16 
17  // ** Add the new 'CrossAccounts' table for each CU that exists in the current database
18  // get the list of credit unions
19  $cuList = $this->fetchAll('SELECT cu FROM cuadmin');
20 
21  for ( $i = 0; $i < count( $cuList ); $i++ ) {
22  $cu = strtolower( trim( $cuList[$i]["cu"] ) );
23 
24  /**
25  * Check for existence of file name
26  */
27  $tableName = "{$cu}crossaccounts";
28 
29  $exists = $this->hasTable($tableName);
30 
31  if (!$exists) {
32  /**
33  * Table does not exist --
34  * CREATE
35  */
36 
37  $sql = "
38  CREATE TABLE {$tableName} (
39  accountnumber character (12) NOT NULL,
40  tomember character(12) NOT NULL,
41  accounttype character(12) NOT NULL,
42  deposittype character (1) NOT NULL,
43  description character varying (255),
44  misc1 character varying (255)
45  );";
46  $sqlRs = $this->query($sql);
47 
48  /* ADD PRIMARY KEY */
49  $sql = "ALTER TABLE ONLY {$tableName} ADD CONSTRAINT {$tableName}_pkey PRIMARY KEY (accountnumber, tomember, accounttype, deposittype);";
50  $sqlRs = $this->query($sql);
51 
52  }
53  }
54  }

The documentation for this class was generated from the following file: