Beispiel #1
0
$scripts->addFile('normalization.js');
$scripts->addFile('jquery/jquery.uitablefilter.js');
$normalForm = '1nf';
if (isset($_REQUEST['normalizeTo'])) {
    $normalForm = $_REQUEST['normalizeTo'];
}
if (isset($_REQUEST['createNewTables2NF'])) {
    $partialDependencies = json_decode($_REQUEST['pd']);
    $tablesName = json_decode($_REQUEST['newTablesName']);
    $res = PMA_createNewTablesFor2NF($partialDependencies, $tablesName, $table, $db);
    $response->addJSON($res);
    exit;
}
if (isset($_REQUEST['createNewTables3NF'])) {
    $newtables = json_decode($_REQUEST['newTables']);
    $res = PMA_createNewTablesFor3NF($newtables, $db);
    $response->addJSON($res);
    exit;
}
if (isset($_POST['repeatingColumns'])) {
    $repeatingColumns = $_POST['repeatingColumns'];
    $newTable = $_POST['newTable'];
    $newColumn = $_POST['newColumn'];
    $primary_columns = $_POST['primary_columns'];
    $res = PMA_moveRepeatingGroup($repeatingColumns, $primary_columns, $newTable, $newColumn, $table, $db);
    $response->addJSON($res);
    exit;
}
if (isset($_REQUEST['step1'])) {
    $html = PMA_getHtmlFor1NFStep1($db, $table, $normalForm);
    $response->addHTML($html);
 /**
  * Test for PMA_createNewTablesFor3NF
  *
  * @return void
  */
 public function testPMACreateNewTablesFor3NF()
 {
     $db = 'PMA_db';
     $cols = new stdClass();
     $cols->pk = 'id';
     $cols->nonpk = 'col1, col2';
     $cols1 = new stdClass();
     $cols1->pk = 'col2';
     $cols1->nonpk = 'col3, col4';
     $newTables = array('PMA_table' => array('PMA_table' => $cols, 'table1' => $cols1));
     $result = PMA_createNewTablesFor3NF($newTables, $db);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('legendText', $result);
     $this->assertArrayHasKey('headText', $result);
     $this->assertArrayHasKey('queryError', $result);
     $newTables1 = array();
     $result1 = PMA_createNewTablesFor3NF($newTables1, $db);
     $this->assertArrayHasKey('queryError', $result1);
     $this->assertEquals(__('End of step'), $result1['legendText']);
     $this->assertEquals(false, $result1['queryError']);
 }