openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

DBVersion000008.class.php (1317B)


      1 <?php
      2 use database\DbVersion;
      3 use security\Password;
      4 
      5 /**
      6  * Creates a type column in table OBJECT. Now added types have no need for new table columns.
      7  * 
      8  * @author dankert
      9  *
     10  */
     11 class DBVersion000008 extends DbVersion
     12 {
     13     /**
     14      *
     15      */
     16     public function update()
     17 	{
     18 		$not_nullable = false;
     19 		$nullable     = true;
     20 
     21         $this->addColumn('object','typeid',OR_DB_COLUMN_TYPE_INT,2,0,$not_nullable);
     22         $this->addIndex('object','typeid');
     23 
     24         // Converting old values...
     25         $db    = $this->getDb();
     26         $table = $this->getTableName('object');
     27 
     28         $updateStmt = $db->sql('UPDATE '.$table.
     29             ' SET typeid=1 WHERE is_folder=1'
     30         );
     31         $updateStmt->query();
     32 
     33         $updateStmt = $db->sql('UPDATE '.$table.
     34             ' SET typeid=2 WHERE is_file=1'
     35         );
     36         $updateStmt->query();
     37 
     38         $updateStmt = $db->sql('UPDATE '.$table.
     39             ' SET typeid=3 WHERE is_page=1'
     40         );
     41         $updateStmt->query();
     42 
     43         $updateStmt = $db->sql('UPDATE '.$table.
     44             ' SET typeid=4 WHERE is_link=1'
     45         );
     46         $updateStmt->query();
     47 
     48         $this->dropColumn('object','is_folder');
     49         $this->dropColumn('object','is_file');
     50         $this->dropColumn('object','is_page');
     51         $this->dropColumn('object','is_link');
     52 	}
     53 }
     54 
     55 ?>