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
35 function __construct(\PMA_DatabaseInterface
$dbi)
41 * Get existing data on transformations applied for
42 * columns in a particular table
44 * @param string $db Database name looking for
46 * @return \mysqli_result Result of executed SQL query
48 public function getExistingTransformationData($db)
50 $cfgRelation = \
PMA_getRelationsParam();
52 // Get the existing transformation details of the same database
53 // from pma__column_info table
54 $pma_transformation_sql = sprintf(
55 "SELECT * FROM %s.%s WHERE `db_name` = '%s'",
56 \PMA_Util
::backquote($cfgRelation['db']),
57 \PMA_Util
::backquote($cfgRelation['column_info']),
58 \PMA_Util
::sqlAddSlashes($db)
61 return $this->dbi
->tryQuery($pma_transformation_sql);
65 * Get SQL query for store new transformation details of a VIEW
67 * @param object $pma_transformation_data Result set of SQL execution
68 * @param array $column_map Details of VIEW columns
69 * @param string $view_name Name of the VIEW
70 * @param string $db Database name of the VIEW
72 * @return string $new_transformations_sql SQL query for new transformations
74 function getNewTransformationDataSql(
75 $pma_transformation_data, $column_map, $view_name, $db
77 $cfgRelation = \
PMA_getRelationsParam();
79 // Need to store new transformation details for VIEW
80 $new_transformations_sql = sprintf(
82 . "`db_name`, `table_name`, `column_name`, "
83 . "`comment`, `mimetype`, `transformation`, "
84 . "`transformation_options`) VALUES",
85 \PMA_Util
::backquote($cfgRelation['db']),
86 \PMA_Util
::backquote($cfgRelation['column_info'])
92 while ($data_row = $this->dbi
->fetchAssoc($pma_transformation_data)) {
94 foreach ($column_map as $column) {
96 if ($data_row['table_name'] != $column['table_name']
97 ||
$data_row['column_name'] != $column['refering_column']
102 $new_transformations_sql .= sprintf(
103 "%s ('%s', '%s', '%s', '%s', '%s', '%s', '%s')",
104 $add_comma ?
', ' : '',
107 isset($column['real_column'])
108 ?
$column['real_column']
109 : $column['refering_column'],
110 $data_row['comment'],
111 $data_row['mimetype'],
112 $data_row['transformation'],
113 \PMA_Util
::sqlAddSlashes(
114 $data_row['transformation_options']
123 if ($column_count == count($column_map)) {
128 return ($column_count > 0) ?
$new_transformations_sql : '';