本文整理匯總了PHP中PMA_query_as_controluser函數的典型用法代碼示例。如果您正苦於以下問題:PHP PMA_query_as_controluser函數的具體用法?PHP PMA_query_as_controluser怎麽用?PHP PMA_query_as_controluser使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了PMA_query_as_controluser函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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->pma_table . " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'";
$row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query));
if (isset($row[0])) {
return json_decode($row[0], true);
} else {
return array();
}
}
示例2: PMA_relationsCleanupDatabase
/**
* Cleanup database related relation stuff
*
* @param string $db
*/
function PMA_relationsCleanupDatabase($db)
{
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['commwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['bookmarkwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['bookmark']) . ' WHERE dbase = \'' . PMA_sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['displaywork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['pdfwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['designerwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['designer_coords']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['relwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation']) . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation']) . ' WHERE foreign_db = \'' . PMA_sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
}
}
示例3: _editCoordinates
/**
* update X and Y coordinates for a table
*
* @param string $db The database name
* @param array $cfgRelation relation settings
*
* @return void
* @access private
*/
private function _editCoordinates($db, $cfgRelation)
{
for ($i = 0; $i < $this->c_table_rows; $i++) {
$arrvalue = 'c_table_' . $i;
global ${$arrvalue};
$arrvalue = ${$arrvalue};
if (!isset($arrvalue['x']) || $arrvalue['x'] == '') {
$arrvalue['x'] = 0;
}
if (!isset($arrvalue['y']) || $arrvalue['y'] == '') {
$arrvalue['y'] = 0;
}
if (isset($arrvalue['name']) && $arrvalue['name'] != '--') {
$test_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\'' . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
$test_rs = PMA_query_as_controluser($test_query, false, PMA_DBI_QUERY_STORE);
//echo $test_query;
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') {
$ch_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\'' . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
} else {
$ch_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' ' . 'SET x = ' . $arrvalue['x'] . ', y= ' . $arrvalue['y'] . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\'' . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
}
} else {
$ch_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' ' . '(db_name, table_name, pdf_page_number, x, y) ' . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\', \'' . PMA_sqlAddSlashes($this->chosenPage) . '\',' . $arrvalue['x'] . ',' . $arrvalue['y'] . ')';
}
//echo $ch_query;
PMA_query_as_controluser($ch_query, false);
}
// end if
}
// end for
}
示例4: __construct
/**
* The "Table_Stats" constructor
*
* @param string table_name The table name
* @param integer pageNumber The current page number (from the
* $cfg['Servers'][$i]['table_coords'] table)
* @param boolean showKeys Whether to display ONLY keys or not
* @return void
* @global object The current dia document
* @global array The relations settings
* @global string The current db name
* @see PMA_DIA
*/
function __construct($tableName, $pageNumber, $showKeys = false)
{
global $dia, $cfgRelation, $db;
$this->tableName = $tableName;
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
$dia->dieSchema($pageNumber, "DIA", 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];
}
}
$sql = 'SELECT x, y FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($tableName) . '\'' . ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
$dia->dieSchema($pageNumber, "DIA", 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 ' . PMA_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'];
}
}
}
/**
* Every object in Dia document needs an ID to identify
* so, we used a static variable to keep the things unique
*/
PMA_Dia_Relation_Schema::$objectId += 1;
$this->tableId = PMA_Dia_Relation_Schema::$objectId;
}
示例5: rename
/**
* renames table
*
* @param string new table name
* @param string new database name
* @return boolean success
*/
function rename($new_name, $new_db = null)
{
if (null !== $new_db && $new_db !== $this->getDbName()) {
// Ensure the target is valid
if (!$GLOBALS['pma']->databases->exists($new_db)) {
$this->errors[] = $GLOBALS['strInvalidDatabase'] . ': ' . $new_db;
return false;
}
} else {
$new_db = $this->getDbName();
}
$new_table = new PMA_Table($new_name, $new_db);
if ($this->getFullName() === $new_table->getFullName()) {
return true;
}
if (!PMA_Table::isValidName($new_name)) {
$this->errors[] = $GLOBALS['strInvalidTableName'] . ': ' . $new_table->getFullName();
return false;
}
$GLOBALS['sql_query'] = '
RENAME TABLE ' . $this->getFullName(true) . '
TO ' . $new_table->getFullName(true) . ';';
if (!PMA_DBI_query($GLOBALS['sql_query'])) {
$this->errors[] = sprintf($GLOBALS['strErrorRenamingTable'], $this->getFullName(), $new_table->getFullName());
return false;
}
$old_name = $this->getName();
$old_db = $this->getDbName();
$this->setName($new_name);
$this->setDbName($new_db);
/**
* @todo move into extra function PMA_Relation::renameTable($new_name, $old_name, $new_db, $old_db)
*/
// garvin: Move old entries from comments to new table
require_once './libraries/relation.lib.php';
$GLOBALS['cfgRelation'] = PMA_getRelationsParam();
if ($GLOBALS['cfgRelation']['commwork']) {
$remove_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info']) . '
SET `db_name` = \'' . PMA_sqlAddslashes($new_db) . '\',
`table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `db_name` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_controluser($remove_query);
unset($remove_query);
}
if ($GLOBALS['cfgRelation']['displaywork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['table_info']) . '
SET `db_name` = \'' . PMA_sqlAddslashes($new_db) . '\',
`table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `db_name` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_controluser($table_query);
unset($table_query);
}
if ($GLOBALS['cfgRelation']['relwork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['relation']) . '
SET `foreign_db` = \'' . PMA_sqlAddslashes($new_db) . '\',
`foreign_table` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `foreign_db` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `foreign_table` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_controluser($table_query);
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['relation']) . '
SET `master_db` = \'' . PMA_sqlAddslashes($new_db) . '\',
`master_table` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `master_db` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `master_table` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_controluser($table_query);
unset($table_query);
}
if ($GLOBALS['cfgRelation']['pdfwork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['table_coords']) . '
SET `db_name` = \'' . PMA_sqlAddslashes($new_db) . '\',
`table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `db_name` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_controluser($table_query);
unset($table_query);
}
if ($GLOBALS['cfgRelation']['designerwork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['designer_coords']) . '
SET `db_name` = \'' . PMA_sqlAddslashes($new_db) . '\',
`table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `db_name` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_controluser($table_query);
unset($table_query);
}
//.........這裏部分代碼省略.........
示例6: PMA_getDisplayField
/**
* @author Ivan A Kirillov (Ivan.A.Kirillov@gmail.com)
* @version $Id$
* @package phpMyAdmin-Designer
*/
/**
*
*/
include_once 'pmd_common.php';
require_once './libraries/relation.lib.php';
$table = $T;
$display_field = $F;
if ($cfgRelation['displaywork']) {
$disp = PMA_getDisplayField($db, $table);
if ($disp) {
if ($display_field != $disp) {
$upd_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . ' SET display_field = \'' . PMA_sqlAddslashes($display_field) . '\'' . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
} else {
$upd_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
}
} elseif ($display_field != '') {
$upd_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . '(db_name, table_name, display_field) ' . ' VALUES(' . '\'' . PMA_sqlAddslashes($db) . '\',' . '\'' . PMA_sqlAddslashes($table) . '\',' . '\'' . PMA_sqlAddslashes($display_field) . '\')';
}
if (isset($upd_query)) {
$upd_rs = PMA_query_as_controluser($upd_query);
}
}
// end if
header("Content-Type: text/xml; charset=utf-8");
header("Cache-Control: no-cache");
die("<root act='save_pos' return='strModifications'></root>");
示例7: __construct
/**
* The "Table_Stats" constructor
*
* @param string table_name The table name
* @param integer ff The font size
* @param integer samewidth The max. with among tables
* @param boolean show_keys Whether to display keys or not
* @param boolean show_info Whether to display table position or not
* @global object The current SVG image 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_SVG, Table_Stats::Table_Stats_setWidth,
Table_Stats::Table_Stats_setHeight
*/
function __construct($tableName, $font, $fontSize, $pageNumber, &$same_wide_width, $showKeys = false, $showInfo = false)
{
global $svg, $cfgRelation, $db;
$this->_tableName = $tableName;
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
$svg->dieSchema($pageNumber, "SVG", 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 ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($tableName) . '\'' . ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
$svg->dieSchema($pageNumber, "SVG", 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 ' . PMA_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'];
}
}
}
}
示例8: PMA_DBI_try_query
$upd_query .= ' ON DELETE ' . $on_delete;
}
if ($on_update != 'nix') {
$upd_query .= ' ON UPDATE ' . $on_update;
}
PMA_DBI_try_query($upd_query) or PMD_return_new(0, __('Error: Relation not added.'));
PMD_return_new(1, __('FOREIGN KEY relation added'));
}
// internal (pmadb) relation
} else {
if ($GLOBALS['cfgRelation']['relwork'] == false) {
PMD_return_new(0, _('General relation features') . ':' . _('Disabled'));
} else {
// no need to recheck if the keys are primary or unique at this point,
// this was checked on the interface part
$q = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '(master_db, master_table, master_field, foreign_db, foreign_table, foreign_field)' . ' values(' . '\'' . PMA_sqlAddslashes($db) . '\', ' . '\'' . PMA_sqlAddslashes($T2) . '\', ' . '\'' . PMA_sqlAddslashes($F2) . '\', ' . '\'' . PMA_sqlAddslashes($db) . '\', ' . '\'' . PMA_sqlAddslashes($T1) . '\',' . '\'' . PMA_sqlAddslashes($F1) . '\')';
if (PMA_query_as_controluser($q, false, PMA_DBI_QUERY_STORE)) {
PMD_return_new(1, __('Internal relation added'));
} else {
PMD_return_new(0, __('Error: Relation not added.'));
}
}
}
function PMD_return_new($b, $ret)
{
global $db, $T1, $F1, $T2, $F2;
header("Content-Type: text/xml; charset=utf-8");
//utf-8 .$_GLOBALS['charset']
header("Cache-Control: no-cache");
die('<root act="relation_new" return="' . $ret . '" b="' . $b . '" DB1="' . urlencode($db) . '" T1="' . urlencode($T1) . '" F1="' . urlencode($F1) . '" DB2="' . urlencode($db) . '" T2="' . urlencode($T2) . '" F2="' . urlencode($F2) . '"></root>');
}
示例9: 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;
}
$test_qry = '
SELECT `mimetype`,
`comment`
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
WHERE `db_name` = \'' . PMA_sqlAddSlashes($db) . '\'
AND `table_name` = \'' . PMA_sqlAddSlashes($table) . '\'
AND `column_name` = \'' . PMA_sqlAddSlashes($key) . '\'';
$test_rs = PMA_query_as_controluser($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_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
SET `mimetype` = \'' . PMA_sqlAddSlashes($mimetype) . '\',
`transformation` = \'' . PMA_sqlAddSlashes($transformation) . '\',
`transformation_options` = \'' . PMA_sqlAddSlashes($transformation_options) . '\'';
} else {
$upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']);
}
$upd_query .= '
WHERE `db_name` = \'' . PMA_sqlAddSlashes($db) . '\'
AND `table_name` = \'' . PMA_sqlAddSlashes($table) . '\'
AND `column_name` = \'' . PMA_sqlAddSlashes($key) . '\'';
} elseif (strlen($mimetype) || strlen($transformation)
|| strlen($transformation_options)) {
$upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
. ' (db_name, table_name, column_name, mimetype, transformation, transformation_options) '
. ' VALUES('
. '\'' . PMA_sqlAddSlashes($db) . '\','
. '\'' . PMA_sqlAddSlashes($table) . '\','
. '\'' . PMA_sqlAddSlashes($key) . '\','
. '\'' . PMA_sqlAddSlashes($mimetype) . '\','
. '\'' . PMA_sqlAddSlashes($transformation) . '\','
. '\'' . PMA_sqlAddSlashes($transformation_options) . '\')';
}
if (isset($upd_query)) {
return PMA_query_as_controluser($upd_query);
} else {
return false;
}
} // end of 'PMA_setMIME()' function
示例10: __construct
/**
* The "PMA_RT" constructor
*
* @param mixed $ The scaling factor
* @param integer $ The page number to draw (from the
* $cfg['Servers'][$i]['table_coords'] table)
* @param boolean $ Whether to display table position or not
* @param boolean $ Was originally whether to use one color per
* relation or not, now enables/disables color
* everywhere, due to some problems printing with color
* @param boolean $ Whether to draw grids or not
* @param boolean $ Whether all tables should have the same width or not
* @param boolean $ Wheter to show all field or only the keys
* @global object The current PDF document
* @global string The current db name
* @global array The relations settings
* @access private
* @see PMA_PDF
*/
function __construct($which_rel, $show_info = 0, $change_color = 0, $show_grid = 0, $all_tab_same_wide = 0, $orientation = 'L', $paper = 'A4', $show_keys = 0)
{
global $pdf, $db, $cfgRelation, $with_doc;
$this->same_wide = $all_tab_same_wide;
// Initializes a new document
$pdf = new PMA_PDF('L', 'mm', $paper);
$pdf->SetTitle(sprintf($GLOBALS['strPdfDbSchema'], $GLOBALS['db'], $which_rel));
$pdf->setCMargin(0);
$pdf->Open();
$pdf->SetAuthor('phpMyAdmin ' . PMA_VERSION);
$pdf->AliasNbPages();
$pdf->AddFont('DejaVuSans', '', 'dejavusans.php');
$pdf->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
$pdf->AddFont('DejaVuSerif', '', 'dejavuserif.php');
$pdf->AddFont('DejaVuSerif', 'B', 'dejavuserifb.php');
$this->ff = PMA_PDF_FONT;
$pdf->SetFont($this->ff, '', 14);
$pdf->SetAutoPageBreak('auto');
// Gets tables on this page
$tab_sql = 'SELECT table_name FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND pdf_page_number = ' . $which_rel;
$tab_rs = PMA_query_as_controluser($tab_sql, null, PMA_DBI_QUERY_STORE);
if (!$tab_rs || !PMA_DBI_num_rows($tab_rs) > 0) {
$pdf->PMA_PDF_die($GLOBALS['strPdfNoTables']);
// die('No tables');
}
while ($curr_table = @PMA_DBI_fetch_assoc($tab_rs)) {
$alltables[] = PMA_sqlAddslashes($curr_table['table_name']);
// $intable = '\'' . implode('\', \'', $alltables) . '\'';
}
// make doc //
if ($with_doc) {
$pdf->SetAutoPageBreak('auto', 15);
$pdf->setCMargin(1);
PMA_RT_DOC($alltables);
$pdf->SetAutoPageBreak('auto');
$pdf->setCMargin(0);
}
$pdf->Addpage();
if ($with_doc) {
$pdf->SetLink($pdf->PMA_links['RT']['-'], -1);
$pdf->Bookmark($GLOBALS['strRelationalSchema']);
$pdf->SetAlias('{00}', $pdf->PageNo());
$this->t_marg = 18;
$this->b_marg = 18;
}
/* snip */
foreach ($alltables as $table) {
if (!isset($this->tables[$table])) {
$this->tables[$table] = new PMA_RT_Table($table, $this->ff, $this->tablewidth, $show_keys, $show_info);
}
if ($this->same_wide) {
$this->tables[$table]->width = $this->tablewidth;
}
$this->PMA_RT_setMinMax($this->tables[$table]);
}
// Defines the scale factor
$this->scale = ceil(max(($this->x_max - $this->x_min) / ($pdf->getFh() - $this->r_marg - $this->l_marg), ($this->y_max - $this->y_min) / ($pdf->getFw() - $this->t_marg - $this->b_marg)) * 100) / 100;
$pdf->PMA_PDF_setScale($this->scale, $this->x_min, $this->y_min, $this->l_marg, $this->t_marg);
// Builds and save the PDF document
$pdf->PMA_PDF_setLineWidthScale(0.1);
if ($show_grid) {
$pdf->SetFontSize(10);
$this->PMA_RT_strokeGrid();
}
$pdf->PMA_PDF_setFontSizeScale(14);
// $sql = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
// . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\' '
// . ' AND foreign_db = \'' . PMA_sqlAddslashes($db) . '\' '
// . ' AND master_table IN (' . $intable . ')'
// . ' AND foreign_table IN (' . $intable . ')';
// $result = PMA_query_as_controluser($sql);
// lem9:
// previous logic was checking master tables and foreign tables
// but I think that looping on every table of the pdf page as a master
// and finding its foreigns is OK (then we can support innodb)
$seen_a_relation = false;
foreach ($alltables as $one_table) {
$exist_rel = PMA_getForeigners($db, $one_table, '', 'both');
if ($exist_rel) {
$seen_a_relation = true;
foreach ($exist_rel as $master_field => $rel) {
//.........這裏部分代碼省略.........
示例11: __
</thead>
<tbody>
<?php
// Print out information about versions
$drop_image_or_text = '';
if (true == $GLOBALS['cfg']['PropertiesIconic']) {
$drop_image_or_text .= '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_drop.png" alt="' . __('Delete tracking data for this table') . '" title="' . __('Delete tracking data for this table') . '" />';
}
if ('both' === $GLOBALS['cfg']['PropertiesIconic'] || false === $GLOBALS['cfg']['PropertiesIconic']) {
$drop_image_or_text .= __('Drop');
}
$style = 'odd';
while ($one_result = PMA_DBI_fetch_array($all_tables_result)) {
list($table_name, $version_number) = $one_result;
$table_query = ' SELECT * FROM ' . PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' . PMA_backquote($GLOBALS['cfg']['Server']['tracking']) . ' WHERE `db_name` = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' AND `table_name` = \'' . PMA_sqlAddslashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
$table_result = PMA_query_as_controluser($table_query);
$version_data = PMA_DBI_fetch_array($table_result);
if ($version_data['tracking_active'] == 1) {
$version_status = __('active');
} else {
$version_status = __('not active');
}
$tmp_link = 'tbl_tracking.php?' . $url_query . '&table=' . htmlspecialchars($version_data['table_name']);
$delete_link = 'db_tracking.php?' . $url_query . '&table=' . htmlspecialchars($version_data['table_name']) . '&delete_tracking=true&';
?>
<tr class="noclick <?php
echo $style;
?>
">
<td><?php
echo htmlspecialchars($version_data['db_name']);
示例12: getAllTables
/**
* get all tables involved or included in page
*
* @param string db name of the database
* @param integer pageNumber page number whose tables will be fetched in an array
* @return Array an array of tables
* @access public
*/
public function getAllTables($db, $pageNumber)
{
global $cfgRelation;
// Get All tables
$tab_sql = 'SELECT table_name FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND pdf_page_number = ' . $pageNumber;
$tab_rs = PMA_query_as_controluser($tab_sql, null, PMA_DBI_QUERY_STORE);
if (!$tab_rs || !PMA_DBI_num_rows($tab_rs) > 0) {
$this->dieSchema('', __('This page does not contain any tables!'));
}
while ($curr_table = @PMA_DBI_fetch_assoc($tab_rs)) {
$alltables[] = PMA_sqlAddslashes($curr_table['table_name']);
}
return $alltables;
}
示例13: rename
/**
* renames table
*
* @param string new table name
* @param string new database name
* @param boolean is this for a VIEW rename?
* @return boolean success
*/
function rename($new_name, $new_db = null, $is_view = false)
{
if (null !== $new_db && $new_db !== $this->getDbName()) {
// Ensure the target is valid
if (!$GLOBALS['pma']->databases->exists($new_db)) {
$this->errors[] = __('Invalid database') . ': ' . $new_db;
return false;
}
} else {
$new_db = $this->getDbName();
}
$new_table = new PMA_Table($new_name, $new_db);
if ($this->getFullName() === $new_table->getFullName()) {
return true;
}
if (!PMA_Table::isValidName($new_name)) {
$this->errors[] = __('Invalid table name') . ': ' . $new_table->getFullName();
return false;
}
if (!$is_view) {
$GLOBALS['sql_query'] = '
ALTER TABLE ' . $this->getName(true) . '
RENAME TO ' . $new_table->getName(true);
} else {
$GLOBALS['sql_query'] = '
ALTER TABLE ' . $this->getFullName(true) . '
RENAME ' . $new_table->getFullName(true) . ';';
}
// I don't think a specific error message for views is necessary
if (!PMA_DBI_query($GLOBALS['sql_query'])) {
$this->errors[] = sprintf(__('Error renaming table %1$s to %2$s'), $this->getFullName(), $new_table->getFullName());
return false;
}
$old_name = $this->getName();
$old_db = $this->getDbName();
$this->setName($new_name);
$this->setDbName($new_db);
/**
* @todo move into extra function PMA_Relation::renameTable($new_name, $old_name, $new_db, $old_db)
*/
// Move old entries from comments to new table
$GLOBALS['cfgRelation'] = PMA_getRelationsParam();
if ($GLOBALS['cfgRelation']['commwork']) {
$remove_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info']) . '
SET `db_name` = \'' . PMA_sqlAddslashes($new_db) . '\',
`table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `db_name` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_controluser($remove_query);
unset($remove_query);
}
if ($GLOBALS['cfgRelation']['displaywork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['table_info']) . '
SET `db_name` = \'' . PMA_sqlAddslashes($new_db) . '\',
`table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `db_name` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_controluser($table_query);
unset($table_query);
}
if ($GLOBALS['cfgRelation']['relwork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['relation']) . '
SET `foreign_db` = \'' . PMA_sqlAddslashes($new_db) . '\',
`foreign_table` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `foreign_db` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `foreign_table` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_controluser($table_query);
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['relation']) . '
SET `master_db` = \'' . PMA_sqlAddslashes($new_db) . '\',
`master_table` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `master_db` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `master_table` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_controluser($table_query);
unset($table_query);
}
if ($GLOBALS['cfgRelation']['pdfwork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['table_coords']) . '
SET `db_name` = \'' . PMA_sqlAddslashes($new_db) . '\',
`table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `db_name` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_controluser($table_query);
unset($table_query);
}
if ($GLOBALS['cfgRelation']['designerwork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['designer_coords']) . '
//.........這裏部分代碼省略.........
示例14: PMA_backquote
<?php
// Now if we already have chosen a page number then we should show the
// tables involved
if (isset($chpage) && $chpage > 0) {
echo "\n";
?>
<hr />
<h2><?php
echo $strSelectTables;
?>
</h2>
<?php
$page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND pdf_page_number = \'' . PMA_sqlAddslashes($chpage) . '\'';
$page_rs = PMA_query_as_controluser($page_query, FALSE, $query_default_option);
$array_sh_page = array();
$draginit = '';
$draginit2 = '';
$reset_draginit = '';
$i = 0;
while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) {
$array_sh_page[] = $temp_sh_page;
}
// garvin: Display WYSIWYG-PDF parts?
if ($cfg['WYSIWYG-PDF']) {
if (!isset($_POST['with_field_names']) && !isset($_POST['showwysiwyg'])) {
$with_field_names = TRUE;
}
?>
<script type="text/javascript" src="./js/dom-drag.js"></script>
示例15: PMA_backquote
}
// end if
}
// end if (!$is_information_schema)
// not sure about displaying the PDF dialog in case db is information_schema
if ($cfgRelation['pdfwork'] && $num_tables > 0) {
?>
<!-- Work on PDF Pages -->
<?php
// We only show this if we find something in the new pdf_pages table
$test_query = '
SELECT *
FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . '
WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$test_rs = PMA_query_as_controluser($test_query, null, PMA_DBI_QUERY_STORE);
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
?>
<!-- PDF schema -->
<form method="post" action="pdf_schema.php">
<fieldset>
<legend>
<?php
echo PMA_generate_common_hidden_inputs($db);
if ($cfg['PropertiesIconic']) {
echo '<img class="icon" src="' . $pmaThemeImage . 'b_view.png"' . ' alt="" width="16" height="16" />';
}
echo $strDisplayPDF;
?>
:
</legend>