DBVersion000016.class.php (2678B)
1 <?php 2 3 use database\DbVersion; 4 use security\Password; 5 6 /** 7 * Converting element types from string to number. 8 * 9 * @author dankert 10 * 11 */ 12 class DBVersion000016 extends DbVersion 13 { 14 /** 15 * 16 */ 17 public function update() 18 { 19 // Type 3 = Text is the default. 20 $this->addColumn('element','typeid',OR_DB_COLUMN_TYPE_INT,0,3,OR_DB_COLUMN_NOT_NULLABLE); 21 22 $db = $this->getDb(); 23 $tableProject = $this->getTableName('element'); 24 25 // Update the types 26 $conversionTable = array( 27 1 => 'date', 28 2 => 'number', 29 3 => 'text', 30 4 => 'info' , 31 5 => 'infodate', 32 6 => 'link' , 33 7 => 'longtext', 34 8 => 'code' , 35 9 => 'dynamic' , 36 10 => 'select' , 37 11 => 'copy' , 38 12 => 'linkinfo', 39 13 => 'linkdate', 40 14 => 'insert' 41 ); 42 43 foreach ($conversionTable as $typeid => $typename ) 44 { 45 $updateStmt = $db->sql(<<<SQL 46 UPDATE $tableProject 47 SET typeid=$typeid WHERE type = '$typename' 48 SQL 49 ); 50 $updateStmt->query(); 51 } 52 53 $this->dropColumn('element','type'); 54 55 56 57 $this->addColumn('element','flags',OR_DB_COLUMN_TYPE_INT,0,0,OR_DB_COLUMN_NOT_NULLABLE); 58 59 $updateStmt = $db->sql(<<<SQL 60 UPDATE $tableProject 61 SET flags=flags+1 WHERE html = 1 62 SQL 63 ); 64 $updateStmt->query(); 65 66 $updateStmt = $db->sql(<<<SQL 67 UPDATE $tableProject 68 SET flags=flags+2 WHERE all_languages = 1 69 SQL 70 ); 71 $updateStmt->query(); 72 73 $updateStmt = $db->sql(<<<SQL 74 UPDATE $tableProject 75 SET flags=flags+4 WHERE writable = 1 76 SQL 77 ); 78 $updateStmt->query(); 79 80 $updateStmt = $db->sql(<<<SQL 81 UPDATE $tableProject 82 SET flags=flags+8 WHERE with_icon = 1 83 SQL 84 ); 85 $updateStmt->query(); 86 87 88 89 $this->addColumn('element','format',OR_DB_COLUMN_TYPE_INT,0,0,OR_DB_COLUMN_NOT_NULLABLE); 90 91 // Format = HTML 92 $updateStmt = $db->sql(<<<SQL 93 UPDATE $tableProject 94 SET format=1 WHERE html = 1 and wiki = 0 95 SQL 96 ); 97 $updateStmt->query(); 98 99 // Format = Wiki 100 $updateStmt = $db->sql(<<<SQL 101 UPDATE $tableProject 102 SET format=2 WHERE wiki = 1 103 SQL 104 ); 105 $updateStmt->query(); 106 107 // Other formats were not supported up to this version. 108 109 // Cleanup 110 $this->dropColumn('element','wiki' ); 111 $this->dropColumn('element','html' ); 112 $this->dropColumn('element','all_languages'); 113 $this->dropColumn('element','writable' ); 114 $this->dropColumn('element','with_icon' ); 115 116 } 117 118 119 } 120 121 ?>