openrat-cms

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

DBVersion000018.class.php (666B)


      1 <?php
      2 
      3 use database\DbVersion;
      4 use security\Password;
      5 
      6 /**
      7  * Elements should have a name and a separate label.
      8  *
      9  * @author dankert
     10  *
     11  */
     12 class DBVersion000018 extends DbVersion
     13 {
     14     /**
     15      *
     16      */
     17     public function update()
     18     {
     19         $this->addColumn('element','label'  ,OR_DB_COLUMN_TYPE_VARCHAR,100,'',OR_DB_COLUMN_NOT_NULLABLE);
     20 
     21         // Initial Value for Labels is the element name.
     22         $tableElement = $this->getTableName('element');
     23 
     24         $updateStmt = $this->getDb()->sql(<<<SQL
     25 UPDATE $tableElement
     26    SET label=name
     27 SQL
     28         );
     29         $updateStmt->query();
     30 
     31         $this->addUniqueIndex('element','templateid,label');
     32     }
     33 }
     34