public function testTable()
 {
     $b = new Behavior();
     $this->assertNull($b->getTable(), 'Behavior Table is null by default');
     $t = new Table();
     $t->setName('fooTable');
     $b->setTable($t);
     $this->assertEquals($b->getTable(), $t, 'setTable() sets the name, and getTable() gets it');
 }
                if ($TRUNCATE == "yes") {
                    $tbl = new Table($Server);
                    $tbl->setOwner($User);
                    $tbl->setName($Tablename);
                    if (!$tbl->Truncate()) {
                        $html .= "<P><B>Table truncating failed.</B></P>";
                    }
                } elseif ($TRUNCATE == "no") {
                    $html .= "<P><B>Table truncating cancelled.</B></P>";
                }
            case "drop2":
                $DROP = getData("DROP");
                if ($DROP == "yes") {
                    $tbl = new Table($Server);
                    $tbl->setOwner($User);
                    $tbl->setName($Tablename);
                    if (!$tbl->Drop()) {
                        $html .= "<P><B>Table dropping failed.</B></P>";
                    }
                } elseif ($DROP == "no") {
                    $html .= "<P><B>Table dropping cancelled.</B></P>";
                }
            default:
                $html .= "<P>Execute SQL Statement:<br>" . "<form action=\"tbl_detail.php\" method=\"post\" enctype=\"application/x-www-form-urlencoded\">" . "<input type=\"hidden\" name=\"Tablename\" value=\"{$Tablename}\">" . "<input type=\"hidden\" name=\"Server\" value=\"{$Server}\">" . "<input type=\"hidden\" name=\"User\" value=\"{$User}\">" . "<input type=\"hidden\" name=\"mode\" value=\"main\">" . "<input type=\"hidden\" name=\"submode\" value=\"execute\">" . "<textarea name=\"statement\" cols=\"80\" rows=\"5\" wrap=\"VIRTUAL\" style=\"width: 400px\"></textarea><br>" . "<input type=\"Submit\" name=\"BUTTON\" value=\"Execute\">";
                $html .= "</form></td></tr></table></p>";
        }
        // end submode content
        break;
    default:
}
// end switch mode
Example #3
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;
 }