/**
  * Adds vendor-specific info for table.
  *
  * @param Table $table
  */
 protected function addTableVendorInfo(Table $table)
 {
     $stmt = $this->dbh->query("SHOW TABLE STATUS LIKE '" . $table->getName() . "'");
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     if (!$this->addVendorInfo) {
         //since we depend on `Engine` in the MysqlPlatform, we have always extract this vendor information
         $row = array('Engine' => $row['Engine']);
     }
     $vi = $this->getNewVendorInfoObject($row);
     $table->addVendorInfo($vi);
     $table->setDescription($row['Comment']);
 }
Example #2
0
 protected function loadData($data)
 {
     $dataObj = new Data($this, (int) $data['id'], (string) $data['name']);
     $dataObj->setLabel((string) $data['label']);
     $dataObj->setType((string) $data['type']);
     $dataObj->setUnparsedMin((string) $data['min']);
     $dataObj->setUnparsedMax((string) $data['max']);
     $dataObj->setUnparsedDefault((string) $data['default']);
     $dataObj->setUnit((string) $data['unit']);
     $dataObj->setRound(isset($data['round']) ? (int) $data['round'] : 2);
     $dataObj->setContent((string) $data['content']);
     $dataObj->setSource((string) $data['source']);
     $dataObj->setUnparsedIndex((string) $data['index']);
     $dataObj->setMemorize((string) $data['memorize'] == '1');
     if ($data->Choices) {
         foreach ($data->Choices->children() as $child) {
             if ($child->getName() == "ChoiceGroup") {
                 $choicegroup = $child;
                 $choiceGroupObj = new ChoiceGroup((string) $choicegroup['label']);
                 foreach ($choicegroup->Choice as $choice) {
                     $choiceObj = new Choice($dataObj, (string) $choice['id'], (string) $choice['value'], (string) $choice['label']);
                     $choiceGroupObj->addChoice($choiceObj);
                 }
                 if ($choicegroup->Source) {
                     $source = $choicegroup->Source;
                     $choiceSourceObj = new ChoiceSource($dataObj, (int) $source['id'], (string) $source['valueColumn'], (string) $source['labelColumn']);
                     $choiceSourceObj->setIdColumn((string) $source['idColumn']);
                     $choiceGroupObj->setChoiceSource($choiceSourceObj);
                 }
                 $dataObj->addChoice($choiceGroupObj);
             } elseif ($child->getName() == "Choice") {
                 $choice = $child;
                 $choiceObj = new Choice($dataObj, (string) $choice['id'], (string) $choice['value'], (string) $choice['label']);
                 $dataObj->addChoice($choiceObj);
             } elseif ($child->getName() == "Source") {
                 $source = $child;
                 $choiceSourceObj = new ChoiceSource($dataObj, (int) $source['id'], (string) $source['valueColumn'], (string) $source['labelColumn']);
                 $choiceSourceObj->setIdColumn((string) $source['idColumn']);
                 $dataObj->setChoiceSource($choiceSourceObj);
                 break;
                 // only one source
             }
         }
     }
     if ($data->Table) {
         $table = $data->Table;
         $tableObj = new Table($dataObj, (string) $table['id']);
         $tableObj->setName((string) $table['name']);
         $tableObj->setLabel((string) $table['label']);
         $tableObj->setDescription((string) $table->Description);
         foreach ($table->Column as $column) {
             $columnObj = new Column($tableObj, (int) $column['id'], (string) $column['name'], (string) $column['type']);
             $columnObj->setLabel((string) $column['label']);
             $tableObj->addColumn($columnObj);
         }
         $dataObj->setTable($tableObj);
     }
     $dataObj->setDescription((string) $data->Description);
     return $dataObj;
 }