require_once './libraries/tbl_views.lib.php'; // If different column names defined for VIEW $view_columns = array(); if (isset($_REQUEST['view']['column_names'])) { $view_columns = explode(',', $_REQUEST['view']['column_names']); } $column_map = PMA_getColumnMap($_REQUEST['view']['as'], $view_columns); $pma_tranformation_data = PMA_getExistingTranformationData($GLOBALS['db']); if ($pma_tranformation_data !== false) { // SQL for store new transformation details of VIEW $new_transformations_sql = PMA_getNewTransformationDataSql( $pma_tranformation_data, $column_map, $_REQUEST['view']['name'], $GLOBALS['db'] ); // Store new transformations if ($new_transformations_sql != '') { PMA_DBI_try_query($new_transformations_sql); } } unset($pma_tranformation_data); if ($GLOBALS['is_ajax_request'] != true) { $message = PMA_Message::success(); include './' . $cfg['DefaultTabDatabase']; } else { $response = PMA_Response::getInstance();
/** * Tests for PMA_getNewTransformationDataSql() method. * * @return void * @test */ public function testPMAGetNewTransformationDataSql() { $dbi = $GLOBALS['dbi']; $value = array('table_name' => "table_name", 'column_name' => "column_name", 'comment' => "comment", 'mimetype' => "mimetype", 'transformation' => "transformation", 'transformation_options' => "transformation_options"); $dbi->expects($this->at(0))->method('fetchAssoc')->will($this->returnValue($value)); $GLOBALS['dbi'] = $dbi; $db = "PMA_db"; $pma_tranformation_data = array(); $column_map = array(array("table_name" => "table_name", "refering_column" => "column_name")); $view_name = "view_name"; $ret = PMA_getNewTransformationDataSql($pma_tranformation_data, $column_map, $view_name, $db); $sql = "INSERT INTO `information_schema`.`column_info` " . "(`db_name`, `table_name`, `column_name`, `comment`, `mimetype`, " . "`transformation`, `transformation_options`) VALUES " . "('PMA_db', 'view_name', 'column_name', 'comment', 'mimetype', " . "'transformation', 'transformation_options')"; $this->assertEquals($sql, $ret); }