Пример #1
0
 public function CalemDataModel($id, $controller, $data = null)
 {
     $this->logger =& LoggerManager::getLogger('CalemDataModel');
     //Initialize
     $this->oid = $id;
     $this->controller = $controller;
     $this->tableDd = CalemFactory::getTableDd($id);
     $this->id = $this->tableDd->getTableName();
     $this->init($data);
 }
Пример #2
0
 public function execute()
 {
     $table = $this->param['table'];
     $flds = $this->param['fields'];
     $tbDd = CalemFactory::getTableDd($table);
     $results = '';
     foreach ($flds as $fld) {
         $fldReq = array('id' => $fld, 'tableId' => $table);
         $fldInfo = $tbDd->getField($fld);
         $fldReq = array_merge($fldReq, $fldInfo);
         try {
             $this->dbHdlr->addField($fldReq);
             $results .= "Added field {$table}.{$fld}\n";
         } catch (CalemDataBoException $de) {
             $results .= "Added field {$table}.{$fld} with exception: " . $de->getEx()->getMessage() . "\n";
         }
     }
     return $results;
 }
Пример #3
0
 public function getTableScript($dbHandler, $table)
 {
     $schema = array();
     //Get table DD
     $tbDd = CalemFactory::getTableDd($table);
     //Dropdown not to store in db for this time.
     if ($this->skipCreateInDb($tbDd)) {
         return $schema;
     }
     $tbDef = $tbDd->getTableDef();
     //Let's create the table script first so that a table is created before its constraints
     $schema[] = $dbHandler->getCreateTable($tbDef);
     //Next, let's add script for primary key and indexes
     foreach ($tbDef as $key => $value) {
         switch ($key) {
             case 'fields':
                 break;
             case 'primary_key':
                 $schema[] = $dbHandler->getCreatePrimaryKey($tbDef['table_name'], $tbDef['table_name'] . '_' . $key, $value);
                 break;
             case 'unique_indexes':
                 $indexes = $tbDef['unique_indexes'];
                 foreach ($indexes as $index => $field_list) {
                     $schema[] = $dbHandler->getCreateUniqueIndex($tbDef['table_name'], $index, $field_list);
                 }
                 break;
             case 'indexes':
                 $indexes = $tbDef['indexes'];
                 foreach ($indexes as $index => $field_list) {
                     $schema[] = $dbHandler->getCreateIndex($tbDef['table_name'], $index, $field_list);
                 }
                 break;
         }
     }
     //Each category of the DD
     return $schema;
 }
Пример #4
0
 public function CalemRecordList($id)
 {
     $this->id = $id;
     $this->recList = array();
     $this->tableDd = CalemFactory::getTableDd($this->id);
 }