2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * hold PMA\libraries\SystemDatabase class
8 namespace PMA\libraries
;
10 require_once 'libraries/database_interface.inc.php';
13 * Class SystemDatabase
20 * @var DatabaseInterface
25 * Get instance of SystemDatabase
27 * @param DatabaseInterface $dbi Database interface for the system database
30 function __construct(DatabaseInterface
$dbi)
36 * Get existing data on transformations applied for
37 * columns in a particular table
39 * @param string $db Database name looking for
41 * @return \mysqli_result Result of executed SQL query
43 public function getExistingTransformationData($db)
45 $cfgRelation = \
PMA_getRelationsParam();
47 // Get the existing transformation details of the same database
48 // from pma__column_info table
49 $pma_transformation_sql = sprintf(
50 "SELECT * FROM %s.%s WHERE `db_name` = '%s'",
51 Util
::backquote($cfgRelation['db']),
52 Util
::backquote($cfgRelation['column_info']),
53 $GLOBALS['dbi']->escapeString($db)
56 return $this->dbi
->tryQuery($pma_transformation_sql);
60 * Get SQL query for store new transformation details of a VIEW
62 * @param object $pma_transformation_data Result set of SQL execution
63 * @param array $column_map Details of VIEW columns
64 * @param string $view_name Name of the VIEW
65 * @param string $db Database name of the VIEW
67 * @return string $new_transformations_sql SQL query for new transformations
69 function getNewTransformationDataSql(
70 $pma_transformation_data, $column_map, $view_name, $db
72 $cfgRelation = \
PMA_getRelationsParam();
74 // Need to store new transformation details for VIEW
75 $new_transformations_sql = sprintf(
77 . "`db_name`, `table_name`, `column_name`, "
78 . "`comment`, `mimetype`, `transformation`, "
79 . "`transformation_options`) VALUES",
80 Util
::backquote($cfgRelation['db']),
81 Util
::backquote($cfgRelation['column_info'])
87 while ($data_row = $this->dbi
->fetchAssoc($pma_transformation_data)) {
89 foreach ($column_map as $column) {
91 if ($data_row['table_name'] != $column['table_name']
92 ||
$data_row['column_name'] != $column['refering_column']
97 $new_transformations_sql .= sprintf(
98 "%s ('%s', '%s', '%s', '%s', '%s', '%s', '%s')",
99 $add_comma ?
', ' : '',
102 isset($column['real_column'])
103 ?
$column['real_column']
104 : $column['refering_column'],
105 $data_row['comment'],
106 $data_row['mimetype'],
107 $data_row['transformation'],
108 $GLOBALS['dbi']->escapeString(
109 $data_row['transformation_options']
118 if ($column_count == count($column_map)) {
123 return ($column_count > 0) ?
$new_transformations_sql : '';