2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * hold PMA\SystemDatabase class
11 if (! defined('PHPMYADMIN')) {
15 require_once 'libraries/database_interface.inc.php';
18 * Class SystemDatabase
25 * @var \PMA_DatabaseInterface
30 * Get instance of SystemDatabase
32 * @param \PMA_DatabaseInterface $dbi Database interface for the system database
34 * @return SystemDatabase
36 function __construct(\PMA_DatabaseInterface
$dbi)
42 * Get existing data on transformations applied for
43 * columns in a particular table
45 * @param string $db Database name looking for
47 * @return \mysqli_result Result of executed SQL query
49 public function getExistingTransformationData($db)
51 $cfgRelation = \
PMA_getRelationsParam();
53 // Get the existing transformation details of the same database
54 // from pma__column_info table
55 $pma_transformation_sql = sprintf(
56 "SELECT * FROM %s.%s WHERE `db_name` = '%s'",
57 \PMA_Util
::backquote($cfgRelation['db']),
58 \PMA_Util
::backquote($cfgRelation['column_info']),
59 \PMA_Util
::sqlAddSlashes($db)
62 return $this->dbi
->tryQuery($pma_transformation_sql);
66 * Get SQL query for store new transformation details of a VIEW
68 * @param object $pma_transformation_data Result set of SQL execution
69 * @param array $column_map Details of VIEW columns
70 * @param string $view_name Name of the VIEW
71 * @param string $db Database name of the VIEW
73 * @return string $new_transformations_sql SQL query for new transformations
75 function getNewTransformationDataSql(
76 $pma_transformation_data, $column_map, $view_name, $db
78 $cfgRelation = \
PMA_getRelationsParam();
80 // Need to store new transformation details for VIEW
81 $new_transformations_sql = sprintf(
83 . "`db_name`, `table_name`, `column_name`, "
84 . "`comment`, `mimetype`, `transformation`, "
85 . "`transformation_options`) VALUES",
86 \PMA_Util
::backquote($cfgRelation['db']),
87 \PMA_Util
::backquote($cfgRelation['column_info'])
93 while ($data_row = $this->dbi
->fetchAssoc($pma_transformation_data)) {
95 foreach ($column_map as $column) {
97 if ($data_row['table_name'] != $column['table_name']
98 ||
$data_row['column_name'] != $column['refering_column']
103 $new_transformations_sql .= sprintf(
104 "%s ('%s', '%s', '%s', '%s', '%s', '%s', '%s')",
105 $add_comma ?
', ' : '',
108 isset($column['real_column'])
109 ?
$column['real_column']
110 : $column['refering_column'],
111 $data_row['comment'],
112 $data_row['mimetype'],
113 $data_row['transformation'],
114 \PMA_Util
::sqlAddSlashes(
115 $data_row['transformation_options']
124 if ($column_count == count($column_map)) {
129 return ($column_count > 0) ?
$new_transformations_sql : '';