本文整理汇总了PHP中PMA_query_as_cu函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_query_as_cu函数的具体用法?PHP PMA_query_as_cu怎么用?PHP PMA_query_as_cu使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_query_as_cu函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_duplicate_table
/**
* Inserts existing entries in a PMA_* table by reading a value from an old entry
*
* @param string The array index, which Relation feature to check
* ('relwork', 'commwork', ...)
* @param string The array index, which PMA-table to update
* ('bookmark', 'relation', ...)
* @param array Which fields will be SELECT'ed from the old entry
* @param array Which fields will be used for the WHERE query
* (array('FIELDNAME' => 'FIELDVALUE'))
* @param array Which fields will be used as new VALUES. These are the important
* keys which differ from the old entry.
* (array('FIELDNAME' => 'NEW FIELDVALUE'))
* @global string relation variable
*
* @author Garvin Hicking <me@supergarv.de>
*/
function PMA_duplicate_table($work, $pma_table, $get_fields, $where_fields, $new_fields)
{
global $cfgRelation;
$last_id = -1;
if ($cfgRelation[$work]) {
$select_parts = array();
$row_fields = array();
foreach ($get_fields as $nr => $get_field) {
$select_parts[] = PMA_backquote($get_field);
$row_fields[$get_field] = 'cc';
}
$where_parts = array();
foreach ($where_fields as $_where => $_value) {
$where_parts[] = PMA_backquote($_where) . ' = \'' . PMA_sqlAddslashes($_value) . '\'';
}
$new_parts = array();
$new_value_parts = array();
foreach ($new_fields as $_where => $_value) {
$new_parts[] = PMA_backquote($_where);
$new_value_parts[] = PMA_sqlAddslashes($_value);
}
$table_copy_query = 'SELECT ' . implode(', ', $select_parts) . ' FROM ' . PMA_backquote($cfgRelation[$pma_table]) . ' WHERE ' . implode(' AND ', $where_parts);
$table_copy_rs = PMA_query_as_cu($table_copy_query);
while ($table_copy_row = @PMA_mysql_fetch_array($table_copy_rs)) {
$value_parts = array();
foreach ($table_copy_row as $_key => $_val) {
if (isset($row_fields[$_key]) && $row_fields[$_key] == 'cc') {
$value_parts[] = PMA_sqlAddslashes($_val);
}
}
$new_table_query = 'INSERT IGNORE INTO ' . PMA_backquote($cfgRelation[$pma_table]) . ' (' . implode(', ', $select_parts) . ', ' . implode(', ', $new_parts) . ')' . ' VALUES ' . ' (\'' . implode('\', \'', $value_parts) . '\', \'' . implode('\', \'', $new_value_parts) . '\')';
$new_table_rs = PMA_query_as_cu($new_table_query);
$last_id = @function_exists('mysql_insert_id') ? @mysql_insert_id() : -1;
}
// end while
return $last_id;
}
return true;
}
示例2: PMA_purgeHistory
/**
* purges SQL history
*
* deletes entries that exceeds $cfg['QueryHistoryMax'], oldest first, for the
* given user
*
* @uses $cfg['QueryHistoryMax']
* @uses $cfg['QueryHistoryDB']
* @uses $GLOBALS['controllink']
* @uses PMA_backquote()
* @uses PMA_sqlAddSlashes()
* @uses PMA_query_as_cu()
* @uses PMA_DBI_fetch_value()
* @param string $username the username
* @access public
*/
function PMA_purgeHistory($username)
{
$cfgRelation = PMA_getRelationsParam();
if (!$GLOBALS['cfg']['QueryHistoryDB'] || !$cfgRelation['historywork']) {
return;
}
if (!$cfgRelation['historywork']) {
return;
}
$search_query = '
SELECT `timevalue`
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '
WHERE `username` = \'' . PMA_sqlAddSlashes($username) . '\'
ORDER BY `timevalue` DESC
LIMIT ' . $GLOBALS['cfg']['QueryHistoryMax'] . ', 1';
if ($max_time = PMA_DBI_fetch_value($search_query, 0, 0, $GLOBALS['controllink'])) {
PMA_query_as_cu('
DELETE FROM
' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '
WHERE `username` = \'' . PMA_sqlAddSlashes($username) . '\'
AND `timevalue` <= \'' . $max_time . '\'');
}
}
示例3: PMA_table_rename
/**
* renames table
*
* @param string old tbale name
* @param string new table name
* @return boolean success
*/
function PMA_table_rename($old_name, $new_name)
{
// Ensure the target is valid
if (count($GLOBALS['dblist']) > 0 && !in_array($GLOBALS['db'], $GLOBALS['dblist'])) {
return false;
}
PMA_DBI_select_db($GLOBALS['db']);
$sql_query = '
ALTER TABLE ' . PMA_backquote($old_name) . '
RENAME ' . PMA_backquote($new_name) . ';';
if (!PMA_DBI_query($sql_query)) {
return false;
}
// garvin: Move old entries from comments to new table
require_once './libraries/relation.lib.php';
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['commwork']) {
$remove_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
SET table_name = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE db_name = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'
AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($remove_query);
unset($remove_query);
}
if ($cfgRelation['displaywork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . '
SET table_name = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE db_name = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'
AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
unset($table_query);
}
if ($cfgRelation['relwork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '
SET foreign_table = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE foreign_db = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'
AND foreign_table = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '
SET master_table = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE master_db = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'
AND master_table = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
unset($table_query);
}
if ($cfgRelation['pdfwork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . '
SET table_name = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE db_name = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'
AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
unset($table_query);
}
return true;
}
示例4: PMA_setMIME
/**
* Set a single mimetype to a certain value.
*
* @param string the name of the db
* @param string the name of the table
* @param string the name of the column
* @param string the mimetype of the column
* @param string the transformation of the column
* @param string the transformation options of the column
* @param string (optional) force delete, will erase any existing comments for this column
*
* @return boolean true, if comment-query was made.
*
* @global array the list of relations settings
*
* @access public
*/
function PMA_setMIME($db, $table, $key, $mimetype, $transformation, $transformation_options, $forcedelete = false)
{
global $cfgRelation;
$test_qry = 'SELECT mimetype, ' . PMA_backquote('comment') . ' FROM ' . PMA_backquote($GLOBALS['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_cu($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);
unset($test_rs);
if (!$forcedelete && (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0 || strlen($row['comment']) > 0)) {
$upd_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . ' SET mimetype = \'' . PMA_sqlAddslashes($mimetype) . '\',' . ' transformation = \'' . PMA_sqlAddslashes($transformation) . '\',' . ' transformation_options = \'' . PMA_sqlAddslashes($transformation_options) . '\'' . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' . ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
} else {
$upd_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['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) . '\'';
}
} elseif (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0) {
$upd_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['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)) {
$upd_rs = PMA_query_as_cu($upd_query);
PMA_DBI_free_result($upd_rs);
unset($upd_rs);
return true;
} else {
return false;
}
}
示例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_List_Database']->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_cu($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_cu($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_cu($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_cu($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_cu($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_cu($table_query);
unset($table_query);
}
//.........这里部分代码省略.........
示例6: PMA_RT
/**
* 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
*
* @global object The current PDF document
* @global string The current db name
* @global array The relations settings
*
* @access private
*
* @see PMA_PDF
*/
function PMA_RT($which_rel, $show_info = 0, $change_color = 0, $show_grid = 0, $all_tab_same_wide = 0, $orientation = 'L', $paper = 'A4')
{
global $pdf, $db, $cfgRelation, $with_doc;
// Font face depends on the current language
$this->ff = str_replace('"', '', substr($GLOBALS['right_font_family'], 0, strpos($GLOBALS['right_font_family'], ',')));
$this->same_wide = $all_tab_same_wide;
// Initializes a new document
$pdf = new PMA_PDF('L', 'mm', $paper);
$pdf->title = sprintf($GLOBALS['strPdfDbSchema'], $GLOBALS['db'], $which_rel);
$pdf->cMargin = 0;
$pdf->Open();
$pdf->SetTitle($pdf->title);
$pdf->SetAuthor('phpMyAdmin ' . PMA_VERSION);
$pdf->AliasNbPages();
// fonts added to phpMyAdmin and considered non-standard by fpdf
// (Note: those tahoma fonts are iso-8859-2 based)
if ($this->ff == 'tahoma') {
$pdf->AddFont('tahoma', '', 'tahoma.php');
$pdf->AddFont('tahoma', 'B', 'tahomab.php');
}
$pdf->SetFont($this->ff, '', 14);
$pdf->SetAutoPageBreak('auto');
// Gets tables on this page
$tab_sql = 'SELECT table_name FROM ' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND pdf_page_number = ' . $which_rel;
$tab_rs = PMA_query_as_cu($tab_sql);
if (!$tab_rs || !mysql_num_rows($tab_rs) > 0) {
$pdf->PMA_PDF_die($GLOBALS['strPdfNoTables']);
// die('No tables');
}
while ($curr_table = @PMA_mysql_fetch_array($tab_rs)) {
$alltables[] = PMA_sqlAddslashes($curr_table['table_name']);
//$intable = '\'' . implode('\', \'', $alltables) . '\'';
}
// make doc //
if ($with_doc) {
$pdf->SetAutoPageBreak('auto', 15);
$pdf->cMargin = 1;
PMA_RT_DOC($alltables);
$pdf->SetAutoPageBreak('auto');
$pdf->cMargin = 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);
}
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->fh - $this->r_marg - $this->l_marg), ($this->y_max - $this->y_min) / ($pdf->fw - $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($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_cu($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
//.........这里部分代码省略.........
示例7: 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(0, 'strErrorRelationAdded');
PMD_return(1, 'strInnoDBRelationAdded');
}
// n o n - I n n o D B
} else {
if ($GLOBALS['cfgRelation']['relwork'] == false) {
PMD_return(0, 'strGeneralRelationFeat:strDisabled');
} 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_cu($q, false, PMA_DBI_QUERY_STORE)) {
PMD_return(1, 'strInternalRelationAdded');
} else {
PMD_return(0, 'strErrorRelationAdded');
}
}
}
function PMD_return($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>');
}
示例8: PMA_getDisplayField
/**
* @author Ivan A Kirillov (Ivan.A.Kirillov@gmail.com)
* @version $Id: pmd_display_field.php 10149 2007-03-20 15:11:15Z cybot_tm $
* @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_cu($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>");
示例9: extract
include_once 'pmd_common.php';
require_once './libraries/relation.lib.php';
extract($_POST, EXTR_SKIP);
extract($_GET, EXTR_SKIP);
$die_save_pos = 0;
include_once 'pmd_save_pos.php';
list($DB1, $T1) = explode(".", $T1);
list($DB2, $T2) = explode(".", $T2);
$tables = PMA_DBI_get_tables_full($db, $T1);
$type_T1 = strtoupper($tables[$T1]['ENGINE']);
$tables = PMA_DBI_get_tables_full($db, $T2);
$type_T2 = strtoupper($tables[$T2]['ENGINE']);
if (PMA_foreignkey_supported($type_T1) && PMA_foreignkey_supported($type_T2) && $type_T1 == $type_T2) {
// InnoDB
$existrel_foreign = PMA_getForeigners($DB2, $T2, '', 'foreign');
if (isset($existrel_foreign[$F2]['constraint'])) {
$upd_query = 'ALTER TABLE ' . PMA_backquote($T2) . ' DROP FOREIGN KEY ' . PMA_backquote($existrel_foreign[$F2]['constraint']);
$upd_rs = PMA_DBI_query($upd_query);
}
} else {
// internal relations
PMA_query_as_cu('DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . $cfg['Server']['relation'] . ' WHERE ' . 'master_db = \'' . PMA_sqlAddslashes($DB2) . '\'' . ' AND master_table = \'' . PMA_sqlAddslashes($T2) . '\'' . ' AND master_field = \'' . PMA_sqlAddslashes($F2) . '\'' . ' AND foreign_db = \'' . PMA_sqlAddslashes($DB1) . '\'' . ' AND foreign_table = \'' . PMA_sqlAddslashes($T1) . '\'' . ' AND foreign_field = \'' . PMA_sqlAddslashes($F1) . '\'', FALSE, PMA_DBI_QUERY_STORE);
}
PMD_return_upd(1, 'strRelationDeleted');
function PMD_return_upd($b, $ret)
{
global $K;
header("Content-Type: text/xml; charset=utf-8");
header("Cache-Control: no-cache");
die('<root act="relation_upd" return="' . $ret . '" b="' . $b . '" K="' . $K . '"></root>');
}
示例10: PMA_REL_create_page
/**
* Create a PDF page
*
* @uses $GLOBALS['strNoDescription']
* @uses PMA_backquote()
* @uses $GLOBALS['cfgRelation']['db']
* @uses PMA_sqlAddslashes()
* @uses PMA_query_as_cu()
* @uses PMA_DBI_insert_id()
* @uses $GLOBALS['controllink']
* @param string $newpage
* @param array $cfgRelation
* @param string $db
* @param string $query_default_option
* @return string $pdf_page_number
*/
function PMA_REL_create_page($newpage, $cfgRelation, $db, $query_default_option) {
if (! isset($newpage) || $newpage == '') {
$newpage = $GLOBALS['strNoDescription'];
}
$ins_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
. ' (db_name, page_descr)'
. ' VALUES (\'' . PMA_sqlAddslashes($db) . '\', \'' . PMA_sqlAddslashes($newpage) . '\')';
PMA_query_as_cu($ins_query, FALSE, $query_default_option);
return PMA_DBI_insert_id(isset($GLOBALS['controllink']) ? $GLOBALS['controllink'] : '');
}
示例11: PMA_purgeHistory
/**
* Set a SQL history entry
*
* @param string the name of the db
* @param string the name of the table
* @param string the username
* @param string the sql query
*
* @return boolean true
*
* @access public
*/
function PMA_purgeHistory($username)
{
global $cfgRelation, $cfg;
$purge_query = 'SELECT timevalue FROM ' . PMA_backquote($cfgRelation['history']) . ' WHERE ';
if (PMA_MYSQL_INT_VERSION >= 40100) {
list($conn_charset) = explode('_', $GLOBALS['collation_connection']);
$purge_query .= 'CONVERT(username USING ' . $conn_charset . ')';
unset($conn_charset);
} else {
$purge_query .= 'username';
}
$purge_query .= ' = \'' . PMA_sqlAddSlashes($username) . '\' ORDER BY timevalue DESC LIMIT ' . $cfg['QueryHistoryMax'] . ', 1';
$purge_rs = PMA_query_as_cu($purge_query);
$i = 0;
$row = PMA_DBI_fetch_row($purge_rs);
PMA_DBI_free_result($purge_rs);
if (is_array($row) && isset($row[0]) && $row[0] > 0) {
$maxtime = $row[0];
// quotes added around $maxtime to prevent a difficult to
// reproduce problem
$remove_rs = PMA_query_as_cu('DELETE FROM ' . PMA_backquote($cfgRelation['history']) . ' WHERE timevalue <= "' . $maxtime . '"');
}
return true;
}
示例12: PMA_importRunQuery
/**
* Runs query inside import buffer. This is needed to allow displaying
* of last SELECT, SHOW or HANDLER results and similar nice stuff.
*
* @uses $GLOBALS['finished'] read and write
* @param string query to run
* @param string query to display, this might be commented
* @param bool whether to use control user for queries
* @access public
*/
function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
{
global $import_run_buffer, $go_sql, $complete_query, $display_query, $sql_query, $my_die, $error, $reload, $skip_queries, $executed_queries, $max_sql_len, $read_multiply, $cfg, $sql_query_disabled, $db, $run_query, $is_superuser;
$read_multiply = 1;
if (isset($import_run_buffer)) {
// Should we skip something?
if ($skip_queries > 0) {
$skip_queries--;
} else {
if (!empty($import_run_buffer['sql']) && trim($import_run_buffer['sql']) != '') {
$max_sql_len = max($max_sql_len, strlen($import_run_buffer['sql']));
if (!$sql_query_disabled) {
$sql_query .= $import_run_buffer['full'];
}
if (!$cfg['AllowUserDropDatabase'] && !$is_superuser && preg_match('@^[[:space:]]*DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE @i', $import_run_buffer['sql'])) {
$GLOBALS['message'] = PMA_Message::error('strNoDropDatabases');
$error = TRUE;
} else {
$executed_queries++;
if ($run_query && $GLOBALS['finished'] && empty($sql) && !$error && (!empty($import_run_buffer['sql']) && preg_match('/^[\\s]*(SELECT|SHOW|HANDLER)/i', $import_run_buffer['sql']) || $executed_queries == 1)) {
$go_sql = TRUE;
if (!$sql_query_disabled) {
$complete_query = $sql_query;
$display_query = $sql_query;
} else {
$complete_query = '';
$display_query = '';
}
$sql_query = $import_run_buffer['sql'];
} elseif ($run_query) {
if ($controluser) {
$result = PMA_query_as_cu($import_run_buffer['sql']);
} else {
$result = PMA_DBI_try_query($import_run_buffer['sql']);
}
$msg = '# ';
if ($result === FALSE) {
// execution failed
if (!isset($my_die)) {
$my_die = array();
}
$my_die[] = array('sql' => $import_run_buffer['full'], 'error' => PMA_DBI_getError());
if ($cfg['VerboseMultiSubmit']) {
$msg .= $GLOBALS['strError'];
}
if (!$cfg['IgnoreMultiSubmitErrors']) {
$error = TRUE;
return;
}
} elseif ($cfg['VerboseMultiSubmit']) {
$a_num_rows = (int) @PMA_DBI_num_rows($result);
$a_aff_rows = (int) @PMA_DBI_affected_rows();
if ($a_num_rows > 0) {
$msg .= $GLOBALS['strRows'] . ': ' . $a_num_rows;
} elseif ($a_aff_rows > 0) {
$a_rows = $msg .= sprintf($GLOBALS['strRowsAffected'], $a_aff_rows);
} else {
$msg .= $GLOBALS['strEmptyResultSet'];
}
}
if (!$sql_query_disabled) {
$sql_query .= $msg . "\n";
}
// If a 'USE <db>' SQL-clause was found and the query succeeded, set our current $db to the new one
if ($result != FALSE && preg_match('@^[\\s]*USE[[:space:]]*([\\S]+)@i', $import_run_buffer['sql'], $match)) {
$db = trim($match[1]);
$db = trim($db, ';');
// for example, USE abc;
$reload = TRUE;
}
if ($result != FALSE && preg_match('@^[\\s]*(DROP|CREATE)[\\s]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)@im', $import_run_buffer['sql'])) {
$reload = TRUE;
}
}
// end run query
}
// end if not DROP DATABASE
} elseif (!empty($import_run_buffer['full'])) {
if ($go_sql) {
$complete_query .= $import_run_buffer['full'];
$display_query .= $import_run_buffer['full'];
} else {
if (!$sql_query_disabled) {
$sql_query .= $import_run_buffer['full'];
}
}
}
// check length of query unless we decided to pass it to sql.php
// (if $run_query is false, we are just displaying so show
// the complete query in the textarea)
//.........这里部分代码省略.........
示例13: get_tab_pos
function get_tab_pos()
{
$stmt = PMA_query_as_cu("SELECT * FROM " . PMA_backquote($GLOBALS['cfgRelation']['designer_coords']), FALSE, PMA_DBI_QUERY_STORE);
if ($stmt) {
while ($t_p = PMA_DBI_fetch_array($stmt, MYSQL_ASSOC)) {
$t_name = $t_p['db_name'] . '.' . $t_p['table_name'];
$tab_pos[$t_name]['X'] = $t_p['x'];
$tab_pos[$t_name]['Y'] = $t_p['y'];
$tab_pos[$t_name]['V'] = $t_p['v'];
$tab_pos[$t_name]['H'] = $t_p['h'];
}
}
return isset($tab_pos) ? $tab_pos : NULL;
}
示例14: PMA_table_move_copy
//.........这里部分代码省略.........
$parsed_sql[$i]['data'] = $target;
/* Generate query back */
$GLOBALS['sql_constraints'] = PMA_SQP_formatHtml($parsed_sql, 'query_only');
$result = PMA_DBI_query($GLOBALS['sql_constraints']);
if (isset($sql_query)) {
$sql_query .= "\n" . $GLOBALS['sql_constraints'];
} else {
$sql_query = $GLOBALS['sql_constraints'];
}
unset($GLOBALS['sql_constraints']);
}
} else {
$sql_query = '';
}
// Copy the data
//if ($result != FALSE && ($what == 'data' || $what == 'dataonly')) {
if ($what == 'data' || $what == 'dataonly') {
$sql_insert_data = 'INSERT INTO ' . $target . ' SELECT * FROM ' . $source;
PMA_DBI_query($sql_insert_data);
$sql_query .= "\n\n" . $sql_insert_data . ';';
}
require_once './libraries/relation.lib.php';
$cfgRelation = PMA_getRelationsParam();
// Drops old table if the user has requested to move it
if ($move) {
// This could avoid some problems with replicated databases, when
// moving table from replicated one to not replicated one
PMA_DBI_select_db($source_db);
$sql_drop_table = 'DROP TABLE ' . $source;
PMA_DBI_query($sql_drop_table);
// garvin: Move old entries from PMA-DBs to new table
if ($cfgRelation['commwork']) {
$remove_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info']) . ' SET table_name = \'' . PMA_sqlAddslashes($target_table) . '\', ' . ' db_name = \'' . PMA_sqlAddslashes($target_db) . '\'' . ' WHERE db_name = \'' . PMA_sqlAddslashes($source_db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($source_table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
// garvin: updating bookmarks is not possible since only a single table is moved,
// and not the whole DB.
// if ($cfgRelation['bookmarkwork']) {
// $remove_query = 'UPDATE ' . PMA_backquote($cfgRelation['bookmark'])
// . ' SET dbase = \'' . PMA_sqlAddslashes($target_db) . '\''
// . ' WHERE dbase = \'' . PMA_sqlAddslashes($source_db) . '\'';
// $rmv_rs = PMA_query_as_cu($remove_query);
// unset($rmv_query);
// }
if ($cfgRelation['displaywork']) {
$table_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_info']) . ' SET db_name = \'' . PMA_sqlAddslashes($target_db) . '\', ' . ' table_name = \'' . PMA_sqlAddslashes($target_table) . '\'' . ' WHERE db_name = \'' . PMA_sqlAddslashes($source_db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($source_table) . '\'';
$tb_rs = PMA_query_as_cu($table_query);
unset($table_query);
unset($tb_rs);
}
if ($cfgRelation['relwork']) {
$table_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation']) . ' SET foreign_table = \'' . PMA_sqlAddslashes($target_table) . '\',' . ' foreign_db = \'' . PMA_sqlAddslashes($target_db) . '\'' . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($source_db) . '\'' . ' AND foreign_table = \'' . PMA_sqlAddslashes($source_table) . '\'';
$tb_rs = PMA_query_as_cu($table_query);
unset($table_query);
unset($tb_rs);
$table_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation']) . ' SET master_table = \'' . PMA_sqlAddslashes($target_table) . '\',' . ' master_db = \'' . PMA_sqlAddslashes($target_db) . '\'' . ' WHERE master_db = \'' . PMA_sqlAddslashes($source_db) . '\'' . ' AND master_table = \'' . PMA_sqlAddslashes($source_table) . '\'';
$tb_rs = PMA_query_as_cu($table_query);
unset($table_query);
unset($tb_rs);
}
// garvin: [TODO] Can't get moving PDFs the right way. The page numbers always
// get screwed up independently from duplication because the numbers do not
// seem to be stored on a per-database basis. Would the author of pdf support
// please have a look at it?
if ($cfgRelation['pdfwork']) {
示例15: PMA_relationsCleanupDatabase
function PMA_relationsCleanupDatabase($db)
{
global $cfgRelation;
if ($cfgRelation['commwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
if ($cfgRelation['bookmarkwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['bookmark']) . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
if ($cfgRelation['displaywork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
if ($cfgRelation['pdfwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
if ($cfgRelation['relwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
}