本文整理汇总了PHP中PMA_queryAsControlUser函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_queryAsControlUser函数的具体用法?PHP PMA_queryAsControlUser怎么用?PHP PMA_queryAsControlUser使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_queryAsControlUser函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPMAQueryAsControlUser
/**
* Test for PMA_queryAsControlUser
*
* @return void
*/
public function testPMAQueryAsControlUser()
{
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$dbi->expects($this->once())
->method('query')
->will($this->returnValue('executeResult1'));
$dbi->expects($this->once())
->method('tryQuery')
->will($this->returnValue('executeResult2'));
$GLOBALS['dbi'] = $dbi;
$sql = "insert into PMA_bookmark A,B values(1, 2)";
$this->assertEquals(
'executeResult1',
PMA_queryAsControlUser($sql)
);
$this->assertEquals(
'executeResult2',
PMA_queryAsControlUser($sql, false)
);
}
示例2: PMA_getPageIdsAndNames
/**
* Retrieve IDs and names of schema pages
*
* @param string $db database name
*
* @return array array of schema page id and names
*/
function PMA_getPageIdsAndNames($db)
{
$cfgRelation = PMA_getRelationsParam();
$page_query = "SELECT `page_nr`, `page_descr` FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['pdf_pages']) . " WHERE db_name = '" . PMA\libraries\Util::sqlAddSlashes($db) . "'" . " ORDER BY `page_descr`";
$page_rs = PMA_queryAsControlUser($page_query, false, PMA\libraries\DatabaseInterface::QUERY_STORE);
$result = array();
while ($curr_page = $GLOBALS['dbi']->fetchAssoc($page_rs)) {
$result[$curr_page['page_nr']] = $curr_page['page_descr'];
}
return $result;
}
示例3: getFromDb
/**
* Returns recently used tables from phpMyAdmin database.
*
* @return array
*/
public function getFromDb()
{
// Read from phpMyAdmin database, if recent tables is not in session
$sql_query = " SELECT `tables` FROM " . $this->_pmaTable . " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'";
$row = PMA_DBI_fetch_array(PMA_queryAsControlUser($sql_query));
if (isset($row[0])) {
return json_decode($row[0], true);
} else {
return array();
}
}
示例4: getFromDb
/**
* Returns recently used tables from phpMyAdmin database.
*
* @return array
*/
public function getFromDb()
{
// Read from phpMyAdmin database, if recent tables is not in session
$sql_query = " SELECT `tables` FROM " . $this->_pmaTable . " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'";
$return = array();
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {
$row = $GLOBALS['dbi']->fetchArray($result);
if (isset($row[0])) {
$return = json_decode($row[0], true);
}
}
return $return;
}
示例5: PMA_handleUpdatesForInternalRelations
/**
* Function to handle updates for internal relations
*
* @param string $destination_db destination database
* @param string $multi_edit_columns_name multi edit column name
* @param string $destination_table destination table
* @param string $destination_column destination column
* @param array $cfgRelation configuration relation
* @param string $db current database
* @param string $table current table
* @param array $existrel db, table, column
*
* @return void
*/
function PMA_handleUpdatesForInternalRelations($destination_db, $multi_edit_columns_name, $destination_table, $destination_column, $cfgRelation, $db, $table, $existrel)
{
foreach ($destination_db as $master_field_md5 => $foreign_db) {
$upd_query = PMA_getQueryForInternalRelationUpdate($multi_edit_columns_name, $master_field_md5, $foreign_db, $destination_table, $destination_column, $cfgRelation, $db, $table, isset($existrel) ? $existrel : null);
if ($upd_query) {
PMA_queryAsControlUser($upd_query);
}
}
}
示例6: PMA_editUserGroup
/**
* Add/update a user group with allowed menu tabs.
*
* @param string $userGroup user group name
* @param boolean $new whether this is a new user group
*
* @return void
*/
function PMA_editUserGroup($userGroup, $new = false)
{
$tabs = PMA_Util::getMenuTabList();
$groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']);
if (!$new) {
$sql_query = "DELETE FROM " . $groupTable . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "';";
PMA_queryAsControlUser($sql_query, true);
}
$sql_query = "INSERT INTO " . $groupTable . "(`usergroup`, `tab`, `allowed`)" . " VALUES ";
$first = true;
foreach ($tabs as $tabGroupName => $tabGroup) {
foreach ($tabs[$tabGroupName] as $tab => $tabName) {
if (!$first) {
$sql_query .= ", ";
}
$tabName = $tabGroupName . '_' . $tab;
$allowed = isset($_REQUEST[$tabName]) && $_REQUEST[$tabName] == 'Y';
$sql_query .= "('" . $userGroup . "', '" . $tabName . "', '" . ($allowed ? "Y" : "N") . "')";
$first = false;
}
}
$sql_query .= ";";
PMA_queryAsControlUser($sql_query, true);
}
示例7: getData
//.........这里部分代码省略.........
$query .= "AND `TABLE_TYPE`='BASE' ";
} else {
$query .= "AND `TABLE_TYPE`='BASE TABLE' ";
}
if (!empty($searchClause)) {
$query .= "AND `TABLE_NAME` LIKE '%";
$query .= PMA_Util::sqlAddSlashes($searchClause, true);
$query .= "%'";
}
$query .= "ORDER BY `TABLE_NAME` ASC ";
$query .= "LIMIT " . intval($pos) . ", {$maxItems}";
$retval = $GLOBALS['dbi']->fetchResult($query);
break;
case 'views':
$escdDb = PMA_Util::sqlAddSlashes($db);
$query = "SELECT `TABLE_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`TABLES` ";
$query .= "WHERE `TABLE_SCHEMA`='{$escdDb}' ";
if (PMA_DRIZZLE) {
$query .= "AND `TABLE_TYPE`!='BASE' ";
} else {
$query .= "AND `TABLE_TYPE`!='BASE TABLE' ";
}
if (!empty($searchClause)) {
$query .= "AND `TABLE_NAME` LIKE '%";
$query .= PMA_Util::sqlAddSlashes($searchClause, true);
$query .= "%'";
}
$query .= "ORDER BY `TABLE_NAME` ASC ";
$query .= "LIMIT " . intval($pos) . ", {$maxItems}";
$retval = $GLOBALS['dbi']->fetchResult($query);
break;
case 'procedures':
$escdDb = PMA_Util::sqlAddSlashes($db);
$query = "SELECT `ROUTINE_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` ";
$query .= "WHERE `ROUTINE_SCHEMA`='{$escdDb}'";
$query .= "AND `ROUTINE_TYPE`='PROCEDURE' ";
if (!empty($searchClause)) {
$query .= "AND `ROUTINE_NAME` LIKE '%";
$query .= PMA_Util::sqlAddSlashes($searchClause, true);
$query .= "%'";
}
$query .= "ORDER BY `ROUTINE_NAME` ASC ";
$query .= "LIMIT " . intval($pos) . ", {$maxItems}";
$retval = $GLOBALS['dbi']->fetchResult($query);
break;
case 'functions':
$escdDb = PMA_Util::sqlAddSlashes($db);
$query = "SELECT `ROUTINE_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` ";
$query .= "WHERE `ROUTINE_SCHEMA`='{$escdDb}' ";
$query .= "AND `ROUTINE_TYPE`='FUNCTION' ";
if (!empty($searchClause)) {
$query .= "AND `ROUTINE_NAME` LIKE '%";
$query .= PMA_Util::sqlAddSlashes($searchClause, true);
$query .= "%'";
}
$query .= "ORDER BY `ROUTINE_NAME` ASC ";
$query .= "LIMIT " . intval($pos) . ", {$maxItems}";
$retval = $GLOBALS['dbi']->fetchResult($query);
break;
case 'events':
$escdDb = PMA_Util::sqlAddSlashes($db);
$query = "SELECT `EVENT_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`EVENTS` ";
$query .= "WHERE `EVENT_SCHEMA`='{$escdDb}' ";
if (!empty($searchClause)) {
$query .= "AND `EVENT_NAME` LIKE '%";
$query .= PMA_Util::sqlAddSlashes($searchClause, true);
$query .= "%'";
}
$query .= "ORDER BY `EVENT_NAME` ASC ";
$query .= "LIMIT " . intval($pos) . ", {$maxItems}";
$retval = $GLOBALS['dbi']->fetchResult($query);
break;
default:
break;
}
// Remove hidden items so that they are not displayed in navigation tree
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$navTable = PMA_Util::backquote($cfgRelation['db']) . "." . PMA_Util::backquote($cfgRelation['navigationhiding']);
$sqlQuery = "SELECT `item_name` FROM " . $navTable . " WHERE `username`='" . $cfgRelation['user'] . "'" . " AND `item_type`='" . $GLOBALS['PMA_String']->substr($type, 0, -1) . "'" . " AND `db_name`='" . PMA_Util::sqlAddSlashes($db) . "'";
$result = PMA_queryAsControlUser($sqlQuery, false);
if ($result) {
$hiddenItems = array();
while ($row = $GLOBALS['dbi']->fetchArray($result)) {
$hiddenItems[] = $row[0];
}
foreach ($retval as $key => $item) {
if (in_array($item, $hiddenItems)) {
unset($retval[$key]);
}
}
}
$GLOBALS['dbi']->freeResult($result);
}
return $retval;
}
示例8: PMA_relationsCleanupUser
/**
* Cleanup user related relation stuff
*
* @param string $username username
*
* @return void
*/
function PMA_relationsCleanupUser($username)
{
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['bookmarkwork']) {
$remove_query = "DELETE FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['bookmark']) . " WHERE `user` = '" . PMA\libraries\Util::sqlAddSlashes($username) . "'";
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['historywork']) {
$remove_query = "DELETE FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['history']) . " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username) . "'";
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['recentwork']) {
$remove_query = "DELETE FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['recent']) . " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username) . "'";
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['favoritework']) {
$remove_query = "DELETE FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['favorite']) . " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username) . "'";
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['uiprefswork']) {
$remove_query = "DELETE FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['table_uiprefs']) . " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username) . "'";
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['userconfigwork']) {
$remove_query = "DELETE FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['userconfig']) . " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username) . "'";
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['menuswork']) {
$remove_query = "DELETE FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['users']) . " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username) . "'";
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['navwork']) {
$remove_query = "DELETE FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['navigationhiding']) . " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username) . "'";
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['savedsearcheswork']) {
$remove_query = "DELETE FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['savedsearches']) . " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username) . "'";
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['designersettingswork']) {
$remove_query = "DELETE FROM " . PMA\libraries\Util::backquote($cfgRelation['db']) . "." . PMA\libraries\Util::backquote($cfgRelation['designer_settings']) . " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username) . "'";
PMA_queryAsControlUser($remove_query);
}
}
示例9: PMA_removeRelation
/**
* Removes a foreign relation
*
* @param string $T1 foreign db.table
* @param string $F1 foreign field
* @param string $T2 master db.table
* @param string $F2 master field
*
* @return array array of success/failure and message
*/
function PMA_removeRelation($T1, $F1, $T2, $F2)
{
list($DB1, $T1) = explode(".", $T1);
list($DB2, $T2) = explode(".", $T2);
$tables = $GLOBALS['dbi']->getTablesFull($DB1, $T1);
$type_T1 = mb_strtoupper($tables[$T1]['ENGINE']);
$tables = $GLOBALS['dbi']->getTablesFull($DB2, $T2);
$type_T2 = mb_strtoupper($tables[$T2]['ENGINE']);
if (PMA_Util::isForeignKeySupported($type_T1) && PMA_Util::isForeignKeySupported($type_T2) && $type_T1 == $type_T2) {
// InnoDB
$existrel_foreign = PMA_getForeigners($DB2, $T2, '', 'foreign');
$foreigner = PMA_searchColumnInForeigners($existrel_foreign, $F2);
if (isset($foreigner['constraint'])) {
$upd_query = 'ALTER TABLE ' . PMA_Util::backquote($DB2) . '.' . PMA_Util::backquote($T2) . ' DROP FOREIGN KEY ' . PMA_Util::backquote($foreigner['constraint']) . ';';
if ($GLOBALS['dbi']->query($upd_query)) {
return array(true, __('FOREIGN KEY relation has been removed.'));
}
$error = $GLOBALS['dbi']->getError();
return array(false, __('Error: FOREIGN KEY relation could not be removed!') . "<br/>" . $error);
}
}
// internal relations
$delete_query = "DELETE FROM " . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . "." . $GLOBALS['cfgRelation']['relation'] . " WHERE " . "master_db = '" . PMA_Util::sqlAddSlashes($DB2) . "'" . " AND master_table = '" . PMA_Util::sqlAddSlashes($T2) . "'" . " AND master_field = '" . PMA_Util::sqlAddSlashes($F2) . "'" . " AND foreign_db = '" . PMA_Util::sqlAddSlashes($DB1) . "'" . " AND foreign_table = '" . PMA_Util::sqlAddSlashes($T1) . "'" . " AND foreign_field = '" . PMA_Util::sqlAddSlashes($F1) . "'";
$result = PMA_queryAsControlUser($delete_query, false, PMA_DatabaseInterface::QUERY_STORE);
if (!$result) {
$error = $GLOBALS['dbi']->getError($GLOBALS['controllink']);
return array(false, __('Error: Internal relation could not be removed!') . "<br/>" . $error);
}
return array(true, __('Internal relation has been removed.'));
}
示例10: PMA_getOptionsForExportTemplates
/**
* Returns HTML for the options in teplate dropdown
*
* @param string $export_type export type - server, database, or table
*
* @return string HTML for the options in teplate dropdown
*/
function PMA_getOptionsForExportTemplates($export_type)
{
$ret = '<option value="">-- ' . __('Select a template') . ' --</option>';
// Get the relation settings
$cfgRelation = PMA_getRelationsParam();
$query = "SELECT `id`, `template_name` FROM " . PMA_Util::backquote($cfgRelation['db']) . '.' . PMA_Util::backquote($cfgRelation['export_templates']) . " WHERE `username` = " . "'" . PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'" . " AND `export_type` = '" . $export_type . "'" . " ORDER BY `template_name`;";
$result = PMA_queryAsControlUser($query);
if ($result) {
while ($row = $GLOBALS['dbi']->fetchAssoc($result, $GLOBALS['controllink'])) {
$ret .= '<option value="' . htmlspecialchars($row['id']) . '"';
if (!empty($_GET['template_id']) && $_GET['template_id'] == $row['id']) {
$ret .= ' selected="selected"';
}
$ret .= '>';
$ret .= htmlspecialchars($row['template_name']) . '</option>';
}
}
return $ret;
}
示例11: __construct
/**
* The "Table_Stats" constructor
*
* @param string $tableName The table name
* @param string $font The font name
* @param integer $fontSize The font size
* @param integer $pageNumber Page number
* @param integer &$same_wide_width The max width among tables
* @param boolean $showKeys Whether to display keys or not
* @param boolean $showInfo Whether to display table position or not
*
* @global object The current eps document
* @global integer The current page number (from the
* $cfg['Servers'][$i]['table_coords'] table)
* @global array The relations settings
* @global string The current db name
*
* @access private
* @see PMA_EPS, Table_Stats::Table_Stats_setWidth,
* Table_Stats::Table_Stats_setHeight
*/
function __construct($tableName, $font, $fontSize, $pageNumber, &$same_wide_width, $showKeys = false, $showInfo = false)
{
global $eps, $cfgRelation, $db;
$common_functions = PMA_CommonFunctions::getInstance();
$this->_tableName = $tableName;
$sql = 'DESCRIBE ' . $common_functions->backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
$eps->dieSchema($pageNumber, "EPS", sprintf(__('The %s table doesn\'t exist!'), $tableName));
}
/*
* load fields
* check to see if it will load all fields or only the foreign keys
*/
if ($showKeys) {
$indexes = PMA_Index::getFromTable($this->_tableName, $db);
$all_columns = array();
foreach ($indexes as $index) {
$all_columns = array_merge($all_columns, array_flip(array_keys($index->getColumns())));
}
$this->fields = array_keys($all_columns);
} else {
while ($row = PMA_DBI_fetch_row($result)) {
$this->fields[] = $row[0];
}
}
$this->_showInfo = $showInfo;
// height and width
$this->_setHeightTable($fontSize);
// setWidth must me after setHeight, because title
// can include table height which changes table width
$this->_setWidthTable($font, $fontSize);
if ($same_wide_width < $this->width) {
$same_wide_width = $this->width;
}
// x and y
$sql = 'SELECT x, y FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'' . ' AND table_name = \'' . $common_functions->sqlAddSlashes($tableName) . '\'' . ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
$eps->dieSchema($pageNumber, "EPS", sprintf(__('Please configure the coordinates for table %s'), $tableName));
}
list($this->x, $this->y) = PMA_DBI_fetch_row($result);
$this->x = (double) $this->x;
$this->y = (double) $this->y;
// displayfield
$this->displayfield = PMA_getDisplayField($db, $tableName);
// index
$result = PMA_DBI_query('SHOW INDEX FROM ' . $common_functions->backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE);
if (PMA_DBI_num_rows($result) > 0) {
while ($row = PMA_DBI_fetch_assoc($result)) {
if ($row['Key_name'] == 'PRIMARY') {
$this->primary[] = $row['Column_name'];
}
}
}
}
示例12: PMA_handleUpdatesForInternalRelations
/**
* Function to handle updates for internal relations
*
* @param array $destination_db destination databases
* @param array $multi_edit_columns_name multi edit column names
* @param array $destination_table destination tables
* @param array $destination_column destination columns
* @param array $cfgRelation configuration relation
* @param string $db current database
* @param string $table current table
* @param array|null $existrel db, table, column
*
* @return string
*/
function PMA_handleUpdatesForInternalRelations($destination_db, $multi_edit_columns_name, $destination_table, $destination_column, $cfgRelation, $db, $table, $existrel)
{
$html_output = '';
$updated = false;
foreach ($destination_db as $master_field_md5 => $foreign_db) {
$upd_query = PMA_getQueryForInternalRelationUpdate($multi_edit_columns_name, $master_field_md5, $foreign_db, $destination_table, $destination_column, $cfgRelation, $db, $table, isset($existrel) ? $existrel : null);
if ($upd_query) {
PMA_queryAsControlUser($upd_query);
$updated = true;
}
}
if ($updated) {
$html_output = PMA_Util::getMessage(__('Internal relations were successfully updated.'), '', 'success');
}
return $html_output;
}
示例13: PMA_handleExportTemplateActions
/**
* Handles export template actions
*
* @param array $cfgRelation Relation configuration
*
* @return void
*/
function PMA_handleExportTemplateActions($cfgRelation)
{
if (isset($_REQUEST['templateId'])) {
$id = $GLOBALS['dbi']->escapeString($_REQUEST['templateId']);
} else {
$id = '';
}
$templateTable = PMA\libraries\Util::backquote($cfgRelation['db']) . '.' . PMA\libraries\Util::backquote($cfgRelation['export_templates']);
$user = $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']);
switch ($_REQUEST['templateAction']) {
case 'create':
$query = "INSERT INTO " . $templateTable . "(" . " `username`, `export_type`," . " `template_name`, `template_data`" . ") VALUES (" . "'" . $user . "', " . "'" . $GLOBALS['dbi']->escapeString($_REQUEST['exportType']) . "', '" . $GLOBALS['dbi']->escapeString($_REQUEST['templateName']) . "', '" . $GLOBALS['dbi']->escapeString($_REQUEST['templateData']) . "');";
break;
case 'load':
$query = "SELECT `template_data` FROM " . $templateTable . " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
break;
case 'update':
$query = "UPDATE " . $templateTable . " SET `template_data` = " . "'" . $GLOBALS['dbi']->escapeString($_REQUEST['templateData']) . "'" . " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
break;
case 'delete':
$query = "DELETE FROM " . $templateTable . " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
break;
default:
$query = '';
break;
}
$result = PMA_queryAsControlUser($query, false);
$response = Response::getInstance();
if (!$result) {
$error = $GLOBALS['dbi']->getError($GLOBALS['controllink']);
$response->setRequestStatus(false);
$response->addJSON('message', $error);
exit;
}
$response->setRequestStatus(true);
if ('create' == $_REQUEST['templateAction']) {
$response->addJSON('data', PMA_getOptionsForExportTemplates($_REQUEST['exportType']));
} elseif ('load' == $_REQUEST['templateAction']) {
$data = null;
while ($row = $GLOBALS['dbi']->fetchAssoc($result, $GLOBALS['controllink'])) {
$data = $row['template_data'];
}
$response->addJSON('data', $data);
}
$GLOBALS['dbi']->freeResult($result);
}
示例14: PMA_saveDesignerSetting
/**
* Save value for a designer setting
*
* @param string $index setting
* @param string $value value
*
* @return bool whether the operation succeeded
*/
function PMA_saveDesignerSetting($index, $value)
{
$cfgRelation = PMA_getRelationsParam();
$cfgDesigner = array('user' => $GLOBALS['cfg']['Server']['user'], 'db' => $cfgRelation['db'], 'table' => $cfgRelation['designer_settings']);
$success = true;
if ($GLOBALS['cfgRelation']['designersettingswork']) {
$orig_data_query = "SELECT settings_data" . " FROM " . PMA_Util::backquote($cfgDesigner['db']) . "." . PMA_Util::backquote($cfgDesigner['table']) . " WHERE username = '" . PMA_Util::sqlAddSlashes($cfgDesigner['user']) . "';";
$orig_data = $GLOBALS['dbi']->fetchSingleRow($orig_data_query, $GLOBALS['controllink']);
if (!empty($orig_data)) {
$orig_data = json_decode($orig_data['settings_data'], true);
$orig_data[$index] = $value;
$orig_data = json_encode($orig_data);
$save_query = "UPDATE " . PMA_Util::backquote($cfgDesigner['db']) . "." . PMA_Util::backquote($cfgDesigner['table']) . " SET settings_data = '" . $orig_data . "'" . " WHERE username = '" . PMA_Util::sqlAddSlashes($cfgDesigner['user']) . "';";
$success = PMA_queryAsControlUser($save_query);
} else {
$save_data = array($index => $value);
$query = "INSERT INTO " . PMA_Util::backquote($cfgDesigner['db']) . "." . PMA_Util::backquote($cfgDesigner['table']) . " (username, settings_data)" . " VALUES('" . $cfgDesigner['user'] . "'," . " '" . json_encode($save_data) . "');";
$success = PMA_queryAsControlUser($query);
}
}
return $success;
}
示例15: PMA_setMIME
/**
* Set a single mimetype to a certain value.
*
* @param string $db the name of the db
* @param string $table the name of the table
* @param string $key the name of the column
* @param string $mimetype the mimetype of the column
* @param string $transformation the transformation of the column
* @param string $transformation_options the transformation options of the column
* @param string $forcedelete force delete, will erase any existing
* comments for this column
*
* @access public
*
* @return boolean true, if comment-query was made.
*/
function PMA_setMIME($db, $table, $key, $mimetype, $transformation, $transformation_options, $forcedelete = false)
{
$cfgRelation = PMA_getRelationsParam();
if (!$cfgRelation['commwork']) {
return false;
}
// convert mimetype to old format (f.e. text_plain)
$mimetype = strtolower($mimetype);
// old format has octet-stream instead of octetstream for mimetype
if (strstr($mimetype, "octetstream")) {
$mimetype = "application_octet-stream";
}
// convert transformation to old format (f.e. text_plain__substring.inc.php)
$transformation = strtolower($transformation);
$transformation = str_replace(".class.php", ".inc.php", $transformation);
$last_pos = strrpos($transformation, "_");
$transformation = substr($transformation, 0, $last_pos) . "_" . substr($transformation, $last_pos);
$test_qry = '
SELECT `mimetype`,
`comment`
FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' . PMA_Util::backquote($cfgRelation['column_info']) . '
WHERE `db_name` = \'' . PMA_Util::sqlAddSlashes($db) . '\'
AND `table_name` = \'' . PMA_Util::sqlAddSlashes($table) . '\'
AND `column_name` = \'' . PMA_Util::sqlAddSlashes($key) . '\'';
$test_rs = PMA_queryAsControlUser($test_qry, true, PMA_DBI_QUERY_STORE);
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
$row = @PMA_DBI_fetch_assoc($test_rs);
PMA_DBI_free_result($test_rs);
if (!$forcedelete && (strlen($mimetype) || strlen($transformation) || strlen($transformation_options) || strlen($row['comment']))) {
$upd_query = '
UPDATE ' . PMA_Util::backquote($cfgRelation['db']) . '.' . PMA_Util::backquote($cfgRelation['column_info']) . '
SET `mimetype` = \'' . PMA_Util::sqlAddSlashes($mimetype) . '\',
`transformation` = \'' . PMA_Util::sqlAddSlashes($transformation) . '\',
`transformation_options` = \'' . PMA_Util::sqlAddSlashes($transformation_options) . '\'';
} else {
$upd_query = 'DELETE FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' . PMA_Util::backquote($cfgRelation['column_info']);
}
$upd_query .= '
WHERE `db_name` = \'' . PMA_Util::sqlAddSlashes($db) . '\'
AND `table_name` = \'' . PMA_Util::sqlAddSlashes($table) . '\'
AND `column_name` = \'' . PMA_Util::sqlAddSlashes($key) . '\'';
} elseif (strlen($mimetype) || strlen($transformation) || strlen($transformation_options)) {
$upd_query = 'INSERT INTO ' . PMA_Util::backquote($cfgRelation['db']) . '.' . PMA_Util::backquote($cfgRelation['column_info']) . ' (db_name, table_name, column_name, mimetype, transformation, transformation_options) ' . ' VALUES(' . '\'' . PMA_Util::sqlAddSlashes($db) . '\',' . '\'' . PMA_Util::sqlAddSlashes($table) . '\',' . '\'' . PMA_Util::sqlAddSlashes($key) . '\',' . '\'' . PMA_Util::sqlAddSlashes($mimetype) . '\',' . '\'' . PMA_Util::sqlAddSlashes($transformation) . '\',' . '\'' . PMA_Util::sqlAddSlashes($transformation_options) . '\')';
}
if (isset($upd_query)) {
return PMA_queryAsControlUser($upd_query);
} else {
return false;
}
}