本文整理汇总了PHP中PMA_DBI_query函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_DBI_query函数的具体用法?PHP PMA_DBI_query怎么用?PHP PMA_DBI_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_DBI_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPage
function getPage($id)
{
global $cfg;
switch ($id) {
case 'bufferpool':
if (PMA_MYSQL_INT_VERSION < 50002) {
return FALSE;
}
// rabus: The following query is only possible because we know
// that we are on MySQL 5 here (checked above)!
// side note: I love MySQL 5 for this. :-)
$res = PMA_DBI_query('SHOW STATUS WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\' OR Variable_name = \'Innodb_page_size\';');
$status = array();
while ($row = PMA_DBI_fetch_row($res)) {
$status[$row[0]] = $row[1];
}
PMA_DBI_free_result($res);
unset($res, $row);
$output = '<table>' . "\n" . ' <thead>' . "\n" . ' <tr>' . "\n" . ' <th colspan="4">' . "\n" . ' ' . $GLOBALS['strBufferPoolUsage'] . "\n" . ' </th>' . "\n" . ' </tr>' . "\n" . ' </thead>' . "\n" . ' <tfoot>' . "\n" . ' <tr>' . "\n" . ' <th>' . "\n" . ' ' . $GLOBALS['strTotalUC'] . "\n" . ' </th>' . "\n" . ' <th colspan="3">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_total']) . ' ' . $GLOBALS['strInnoDBPages'] . ' / ' . join(' ', PMA_formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])) . "\n" . ' </th>' . "\n" . ' </tr>' . "\n" . ' </tfoot>' . "\n" . ' <tbody>' . "\n" . ' <tr>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . $GLOBALS['strFreePages'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_free']) . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strDirtyPages'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_dirty']) . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strDataPages'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_data']) . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strPagesToBeFlushed'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_flushed']) . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . $GLOBALS['strBusyPages'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_misc']) . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strLatchedPages'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_latched']) . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' </tbody>' . "\n" . '</table>' . "\n\n" . '<br />' . "\n\n" . '<table>' . "\n" . ' <thead>' . "\n" . ' <tr>' . "\n" . ' <th colspan="4">' . "\n" . ' ' . $GLOBALS['strBufferPoolActivity'] . "\n" . ' </th>' . "\n" . ' </tr>' . "\n" . ' </thead>' . "\n" . ' <tbody>' . "\n" . ' <tr>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strReadRequests'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_read_requests']) . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strWriteRequests'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_write_requests']) . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . $GLOBALS['strBufferReadMisses'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_reads']) . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . $GLOBALS['strBufferWriteWaits'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_wait_free']) . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strBufferReadMissesInPercent'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . ($status['Innodb_buffer_pool_read_requests'] == 0 ? '---' : htmlspecialchars(number_format($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 2, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator'])) . ' %') . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strBufferWriteWaitsInPercent'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . ($status['Innodb_buffer_pool_write_requests'] == 0 ? '---' : htmlspecialchars(number_format($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 2, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator'])) . ' %') . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' </tbody>' . "\n" . '</table>' . "\n";
return $output;
case 'status':
$res = PMA_DBI_query('SHOW INNODB STATUS;');
$row = PMA_DBI_fetch_row($res);
PMA_DBI_free_result($res);
return '<pre>' . "\n" . htmlspecialchars($row[0]) . "\n" . '</pre>' . "\n";
default:
return FALSE;
}
}
示例2: PMA_query_as_cu
/**
* Executes a query as controluser if possible, otherwise as normal user
*
* @param string the query to execute
* @param boolean whether to display SQL error messages or not
*
* @return integer the result id
*
* @access public
*
* @author Mike Beck <mikebeck@users.sourceforge.net>
*/
function PMA_query_as_cu($sql, $show_error = true, $options = 0)
{
// Comparing resource ids works on PHP 5 because, when no controluser
// is defined, connecting with the same user for controllink does
// not create a new connection. However a new connection is created
// on PHP 4, so we cannot directly compare resource ids.
if ($GLOBALS['controllink'] == $GLOBALS['userlink'] || PMA_MYSQL_INT_VERSION < 50000) {
PMA_DBI_select_db($GLOBALS['cfg']['Server']['pmadb'], $GLOBALS['controllink']);
}
if ($show_error) {
$result = PMA_DBI_query($sql, $GLOBALS['controllink'], $options);
} else {
$result = @PMA_DBI_try_query($sql, $GLOBALS['controllink'], $options);
}
// end if... else...
// It makes no sense to restore database on control user
if ($GLOBALS['controllink'] == $GLOBALS['userlink'] || PMA_MYSQL_INT_VERSION < 50000) {
PMA_DBI_select_db($GLOBALS['db'], $GLOBALS['controllink']);
}
if ($result) {
return $result;
} else {
return false;
}
}
示例3: PMA_generateEngineDetails
function PMA_generateEngineDetails($variables, $like = NULL, $indent = 0)
{
global $cfg;
$spaces = '';
for ($i = 0; $i < $indent; $i++) {
$spaces .= ' ';
}
/**
* Get the variables!
*/
if (!empty($variables)) {
$sql_query = 'SHOW ' . (PMA_MYSQL_INT_VERSION >= 40102 ? 'GLOBAL ' : '') . 'VARIABLES' . (empty($like) ? '' : ' LIKE \'' . $like . '\'') . ';';
$res = PMA_DBI_query($sql_query);
$mysql_vars = array();
while ($row = PMA_DBI_fetch_row($res)) {
if (isset($variables[$row[0]])) {
$mysql_vars[$row[0]] = $row[1];
}
}
PMA_DBI_free_result($res);
unset($res, $row, $sql_query);
}
if (empty($mysql_vars)) {
return $spaces . '<p>' . "\n" . $spaces . ' ' . $GLOBALS['strNoDetailsForEngine'] . "\n" . $spaces . '</p>' . "\n";
}
$dt_table = $spaces . '<table>' . "\n";
$useBgcolorOne = TRUE;
$has_content = FALSE;
foreach ($variables as $var => $details) {
if (!isset($mysql_vars[$var])) {
continue;
}
if (!isset($details['type'])) {
$details['type'] = PMA_ENGINE_DETAILS_TYPE_PLAINTEXT;
}
$is_num = $details['type'] == PMA_ENGINE_DETAILS_TYPE_SIZE || $details['type'] == PMA_ENGINE_DETAILS_TYPE_NUMERIC;
$bgcolor = $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
$dt_table .= $spaces . ' <tr>' . "\n" . $spaces . ' <td bgcolor="' . $bgcolor . '">' . "\n";
if (!empty($variables[$var]['desc'])) {
$dt_table .= $spaces . ' ' . PMA_showHint($details['desc']) . "\n";
}
$dt_table .= $spaces . ' </td>' . "\n" . $spaces . ' <td bgcolor="' . $bgcolor . '">' . "\n" . $spaces . ' ' . $details['title'] . ' ' . "\n" . $spaces . ' </td>' . "\n" . $spaces . ' <td bgcolor="' . $bgcolor . '"' . ($is_num ? ' align="right"' : '') . '>' . "\n" . $spaces . ' ';
switch ($details['type']) {
case PMA_ENGINE_DETAILS_TYPE_SIZE:
$parsed_size = PMA_formatByteDown($mysql_vars[$var]);
$dt_table .= $parsed_size[0] . ' ' . $parsed_size[1];
unset($parsed_size);
break;
default:
$dt_table .= htmlspecialchars($mysql_vars[$var]);
}
$dt_table .= ' ' . "\n" . $spaces . ' </td>' . "\n" . $spaces . ' </tr>' . "\n";
$useBgcolorOne = !$useBgcolorOne;
$has_content = TRUE;
}
if (!$has_content) {
return '';
}
return $dt_table;
}
示例4: PMA_getSearchSqls
/**
* Builds the SQL search query
*
* @param string the table name
* @param string the string to search
* @param integer type of search (1 -> 1 word at least, 2 -> all words,
* 3 -> exact string, 4 -> regexp)
*
* @return array 3 SQL querys (for count, display and delete results)
*
* @global string the url to return to in case of errors
*/
function PMA_getSearchSqls($table, $search_str, $search_option)
{
global $err_url, $charset_connection;
// Statement types
$sqlstr_select = 'SELECT';
$sqlstr_delete = 'DELETE';
// Fields to select
$res = PMA_DBI_query('SHOW ' . (PMA_MYSQL_INT_VERSION >= 40100 ? 'FULL ' : '') . 'FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($GLOBALS['db']) . ';');
while ($current = PMA_DBI_fetch_assoc($res)) {
if (PMA_MYSQL_INT_VERSION >= 40100) {
list($current['Charset']) = explode('_', $current['Collation']);
}
$current['Field'] = PMA_backquote($current['Field']);
$tblfields[] = $current;
}
// while
PMA_DBI_free_result($res);
unset($current, $res);
$tblfields_cnt = count($tblfields);
// Table to use
$sqlstr_from = ' FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table);
// Beginning of WHERE clause
$sqlstr_where = ' WHERE';
$search_words = $search_option > 2 ? array($search_str) : explode(' ', $search_str);
$search_wds_cnt = count($search_words);
$like_or_regex = $search_option == 4 ? 'REGEXP' : 'LIKE';
$automatic_wildcard = $search_option < 3 ? '%' : '';
for ($i = 0; $i < $search_wds_cnt; $i++) {
// Eliminates empty values
// In MySQL 4.1, if a field has no collation we get NULL in Charset
// but in MySQL 5.0.x we get ''
if (!empty($search_words[$i])) {
for ($j = 0; $j < $tblfields_cnt; $j++) {
if (PMA_MYSQL_INT_VERSION >= 40100 && $tblfields[$j]['Charset'] != $charset_connection && $tblfields[$j]['Charset'] != 'NULL' && $tblfields[$j]['Charset'] != '') {
$prefix = 'CONVERT(_utf8 ';
$suffix = ' USING ' . $tblfields[$j]['Charset'] . ') COLLATE ' . $tblfields[$j]['Collation'];
} else {
$prefix = $suffix = '';
}
$thefieldlikevalue[] = $tblfields[$j]['Field'] . ' ' . $like_or_regex . ' ' . $prefix . '\'' . $automatic_wildcard . $search_words[$i] . $automatic_wildcard . '\'' . $suffix;
}
// end for
$fieldslikevalues[] = $search_wds_cnt > 1 ? '(' . implode(' OR ', $thefieldlikevalue) . ')' : implode(' OR ', $thefieldlikevalue);
unset($thefieldlikevalue);
}
// end if
}
// end for
$implode_str = $search_option == 1 ? ' OR ' : ' AND ';
$sqlstr_where .= ' ' . implode($implode_str, $fieldslikevalues);
unset($fieldslikevalues);
// Builds complete queries
$sql['select_fields'] = $sqlstr_select . ' * ' . $sqlstr_from . $sqlstr_where;
// here, I think we need to still use the COUNT clause, even for
// VIEWs, anyway we have a WHERE clause that should limit results
$sql['select_count'] = $sqlstr_select . ' COUNT(*) AS count' . $sqlstr_from . $sqlstr_where;
$sql['delete'] = $sqlstr_delete . $sqlstr_from . $sqlstr_where;
return $sql;
}
示例5: get_script_contr
/**
* returns JavaScript code for intializing vars
*
* @return string JavaScript code
*/
function get_script_contr()
{
PMA_DBI_select_db($GLOBALS['db']);
$con["C_NAME"] = array();
$i = 0;
$alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($GLOBALS['db']), null, PMA_DBI_QUERY_STORE);
while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
$row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'internal');
//echo "<br> internal ".$GLOBALS['db']." - ".$val[0]." - ";
//print_r($row);
if ($row !== false) {
foreach ($row as $field => $value) {
$con['C_NAME'][$i] = '';
$con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]);
$con['DCN'][$i] = urlencode($field);
$con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']);
$con['SCN'][$i] = urlencode($value['foreign_field']);
$i++;
}
}
$row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'foreign');
//echo "<br> INNO ";
//print_r($row);
if ($row !== false) {
foreach ($row as $field => $value) {
$con['C_NAME'][$i] = '';
$con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]);
$con['DCN'][$i] = urlencode($field);
$con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']);
$con['SCN'][$i] = urlencode($value['foreign_field']);
$i++;
}
}
}
$ti = 0;
$script_contr = '<script type="text/javascript">' . "\n" . '// <![CDATA[' . "\n" . 'var contr = new Array();' . "\n";
for ($i = 0, $cnt = count($con["C_NAME"]); $i < $cnt; $i++) {
$js_var = ' contr[' . $ti . ']';
$script_contr .= $js_var . " = new Array();\n";
$js_var .= "['" . $con['C_NAME'][$i] . "']";
$script_contr .= $js_var . " = new Array();\n";
if (in_array($con['DTN'][$i], $GLOBALS['PMD_URL']["TABLE_NAME"]) && in_array($con['STN'][$i], $GLOBALS['PMD_URL']["TABLE_NAME"])) {
$js_var .= "['" . $con['DTN'][$i] . "']";
$script_contr .= $js_var . " = new Array();\n";
$m_col = array();
//}
$js_var .= "['" . $con['DCN'][$i] . "']";
$script_contr .= $js_var . " = new Array();\n";
//}
$script_contr .= $js_var . "[0] = '" . $con['STN'][$i] . "';\n";
//
$script_contr .= $js_var . "[1] = '" . $con['SCN'][$i] . "';\n";
//
}
$ti++;
}
$script_contr .= '// ]]>' . "\n" . '</script>' . "\n";
return $script_contr;
}
示例6: PMA_generateEngineDetails
/**
* Function for displaying the table of an engine's parameters
*
* @param array List of MySQL variables and corresponding localized descriptions.
* The array elements should have the following format:
* $variable => array('title' => $title, 'desc' => $description);
* @param string Prefix for the SHOW VARIABLES query.
* @return string The table that was generated based on the given information.
*/
function PMA_generateEngineDetails($variables, $like = null)
{
/**
* Get the variables!
*/
if (!empty($variables)) {
$sql_query = 'SHOW ' . (PMA_MYSQL_INT_VERSION >= 40102 ? 'GLOBAL ' : '') . 'VARIABLES' . (empty($like) ? '' : ' LIKE \'' . $like . '\'') . ';';
$res = PMA_DBI_query($sql_query);
$mysql_vars = array();
while ($row = PMA_DBI_fetch_row($res)) {
if (isset($variables[$row[0]])) {
$mysql_vars[$row[0]] = $row[1];
}
}
PMA_DBI_free_result($res);
unset($res, $row, $sql_query);
}
if (empty($mysql_vars)) {
return '<p>' . "\n" . ' ' . $GLOBALS['strNoDetailsForEngine'] . "\n" . '</p>' . "\n";
}
$dt_table = '<table class="data" cellspacing="1">' . "\n";
$odd_row = false;
$has_content = false;
foreach ($variables as $var => $details) {
if (!isset($mysql_vars[$var])) {
continue;
}
if (!isset($details['type'])) {
$details['type'] = PMA_ENGINE_DETAILS_TYPE_PLAINTEXT;
}
$is_num = $details['type'] == PMA_ENGINE_DETAILS_TYPE_SIZE || $details['type'] == PMA_ENGINE_DETAILS_TYPE_NUMERIC;
$dt_table .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">' . "\n" . ' <td>' . "\n";
if (!empty($variables[$var]['desc'])) {
$dt_table .= ' ' . PMA_showHint($details['desc']) . "\n";
}
$dt_table .= ' </td>' . "\n" . ' <th>' . htmlspecialchars(empty($details['title']) ? $var : $details['title']) . "\n" . ' </th>' . "\n" . ' <td class="value">';
switch ($details['type']) {
case PMA_ENGINE_DETAILS_TYPE_SIZE:
$parsed_size = PMA_formatByteDown($mysql_vars[$var]);
$dt_table .= $parsed_size[0] . ' ' . $parsed_size[1];
unset($parsed_size);
break;
case PMA_ENGINE_DETAILS_TYPE_NUMERIC:
$dt_table .= PMA_formatNumber($mysql_vars[$var]) . ' ';
break;
default:
$dt_table .= htmlspecialchars($mysql_vars[$var]) . ' ';
}
$dt_table .= '</td>' . "\n" . '</tr>' . "\n";
$odd_row = !$odd_row;
$has_content = true;
}
if (!$has_content) {
return '';
}
$dt_table .= '</table>' . "\n";
return $dt_table;
}
示例7: get_script_contr
function get_script_contr()
{
global $db;
PMA_DBI_select_db($db);
$con["C_NAME"] = array();
$i = 0;
$alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db), NULL, PMA_DBI_QUERY_STORE);
while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
$row = PMA_getForeigners($db, $val[0], '', 'internal');
//echo "<br> internal ".$db." - ".$val[0]." - ";
//print_r($row );
if ($row !== false) {
foreach ($row as $field => $value) {
$con['C_NAME'][$i] = '';
$con['DTN'][$i] = urlencode($db . "." . $val[0]);
$con['DCN'][$i] = urlencode($field);
$con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']);
$con['SCN'][$i] = urlencode($value['foreign_field']);
$i++;
}
}
$row = PMA_getForeigners($db, $val[0], '', 'innodb');
//echo "<br> INNO ";
//print_r($row );
if ($row !== false) {
foreach ($row as $field => $value) {
$con['C_NAME'][$i] = '';
$con['DTN'][$i] = urlencode($db . "." . $val[0]);
$con['DCN'][$i] = urlencode($field);
$con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']);
$con['SCN'][$i] = urlencode($value['foreign_field']);
$i++;
}
}
}
$ti = 0;
$script_contr = "<script>\n var contr = new Array();\n";
for ($i = 0; $i < sizeof($con["C_NAME"]); $i++) {
$script_contr .= " contr[{$ti}] = new Array();\n";
$script_contr .= " contr[{$ti}]['" . $con['C_NAME'][$i] . "'] = new Array();\n";
if (in_array($con['DTN'][$i], $GLOBALS['PMD_URL']["TABLE_NAME"]) && in_array($con['STN'][$i], $GLOBALS['PMD_URL']["TABLE_NAME"])) {
$script_contr .= " contr[{$ti}]['" . $con['C_NAME'][$i] . "']['" . $con['DTN'][$i] . "'] = new Array();\n";
$m_col = array();
//}
$script_contr .= " contr[{$ti}]['" . $con['C_NAME'][$i] . "']['" . $con['DTN'][$i] . "']['" . $con['DCN'][$i] . "'] = new Array();\n";
//}
$script_contr .= " contr[{$ti}]['" . $con['C_NAME'][$i] . "']['" . $con['DTN'][$i] . "']['" . $con['DCN'][$i] . "'][0] = '" . $con['STN'][$i] . "';\n";
//
$script_contr .= " contr[{$ti}]['" . $con['C_NAME'][$i] . "']['" . $con['DTN'][$i] . "']['" . $con['DCN'][$i] . "'][1] = '" . $con['SCN'][$i] . "';\n";
//
}
$ti++;
}
$script_contr .= "</script>\n";
return $script_contr;
}
示例8: PMA_get_indexes
/**
* Function to get all index information from a certain table
*
* @param string Table name
* @param string Error URL
*
* @access public
* @return array Index keys
*/
function PMA_get_indexes($tbl_name, $err_url_0 = '')
{
$tbl_local_query = 'SHOW KEYS FROM ' . PMA_backquote($tbl_name);
$tbl_result = PMA_DBI_query($tbl_local_query) or PMA_mysqlDie('', $tbl_local_query, '', $err_url_0);
$tbl_ret_keys = array();
while ($tbl_row = PMA_DBI_fetch_assoc($tbl_result)) {
$tbl_ret_keys[] = $tbl_row;
}
PMA_DBI_free_result($tbl_result);
return $tbl_ret_keys;
}
示例9: get_script_contr
/**
* returns JavaScript code for intializing vars
*
* @return string JavaScript code
*/
function get_script_contr()
{
PMA_DBI_select_db($GLOBALS['db']);
$con["C_NAME"] = array();
$i = 0;
$alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_Util::backquote($GLOBALS['db']), null, PMA_DBI_QUERY_STORE);
while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
$row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'internal');
//echo "<br> internal ".$GLOBALS['db']." - ".$val[0]." - ";
//print_r($row);
if ($row !== false) {
foreach ($row as $field => $value) {
$con['C_NAME'][$i] = '';
$con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]);
$con['DCN'][$i] = urlencode($field);
$con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']);
$con['SCN'][$i] = urlencode($value['foreign_field']);
$i++;
}
}
$row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'foreign');
//echo "<br> INNO ";
//print_r($row);
if ($row !== false) {
foreach ($row as $field => $value) {
$con['C_NAME'][$i] = '';
$con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]);
$con['DCN'][$i] = urlencode($field);
$con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']);
$con['SCN'][$i] = urlencode($value['foreign_field']);
$i++;
}
}
}
$ti = 0;
$retval = array();
for ($i = 0, $cnt = count($con["C_NAME"]); $i < $cnt; $i++) {
$c_name_i = $con['C_NAME'][$i];
$dtn_i = $con['DTN'][$i];
$retval[$ti] = array();
$retval[$ti][$c_name_i] = array();
if (in_array($dtn_i, $GLOBALS['PMD_URL']["TABLE_NAME"]) && in_array($con['STN'][$i], $GLOBALS['PMD_URL']["TABLE_NAME"])) {
$retval[$ti][$c_name_i][$dtn_i] = array();
$retval[$ti][$c_name_i][$dtn_i][$con['DCN'][$i]] = array(0 => $con['STN'][$i], 1 => $con['SCN'][$i]);
}
$ti++;
}
return $retval;
}
示例10: get_tab_info
/**
* retrieves table column info
*
* @uses $GLOBALS['db']
* @uses PMA_DBI_QUERY_STORE
* @uses PMA_DBI_select_db()
* @uses PMA_DBI_query()
* @uses PMA_DBI_num_rows()
* @uses PMA_backquote()
* @uses count()
* @return array table column nfo
*/
function get_tab_info()
{
PMA_DBI_select_db($GLOBALS['db']);
$tab_column = array();
for ($i = 0, $cnt = count($GLOBALS['PMD']["TABLE_NAME"]); $i < $cnt; $i++) {
$fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]), NULL, PMA_DBI_QUERY_STORE);
$j = 0;
while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
$tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['COLUMN_ID'][$j] = $j;
$tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['COLUMN_NAME'][$j] = $row['Field'];
$tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['TYPE'][$j] = $row['Type'];
$tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['NULLABLE'][$j] = $row['Null'];
$j++;
}
}
return $tab_column;
}
示例11: PMA_DBI_get_fields_meta
echo "\n";
require_once './libraries/footer.inc.php';
} else {
// end if (no row returned)
$meta = PMA_DBI_get_fields_meta($result[$key_id]);
list($unique_condition, $tmp_clause_is_unique) = PMA_getUniqueCondition($result[$key_id], count($meta), $meta, $rows[$key_id], true);
if (!empty($unique_condition)) {
$found_unique_key = true;
}
unset($unique_condition, $tmp_clause_is_unique);
}
}
} else {
// no primary key given, just load first row - but what happens if table is empty?
$insert_mode = true;
$result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE);
$rows = array_fill(0, $cfg['InsertRows'], false);
}
// <markus@noga.de>
// retrieve keys into foreign fields, if any
$foreigners = PMA_getForeigners($db, $table);
/**
* Displays the form
*/
// loic1: autocomplete feature of IE kills the "onchange" event handler and it
// must be replaced by the "onpropertychange" one in this case
$chg_evt_handler = PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5 && PMA_USR_BROWSER_VER < 7 ? 'onpropertychange' : 'onchange';
// Had to put the URI because when hosted on an https server,
// some browsers send wrongly this form to the http server.
if ($cfg['CtrlArrowsMoving']) {
?>
示例12: PMA_DBI_query
$message .= PMA_DBI_query($sql_query) ? $strSuccess : $strError;
$reread_info = true;
unset($table_alters);
}
}
/**
* Reordering the table has been requested by the user
*/
if (isset($_REQUEST['submitorderby']) && !empty($_REQUEST['order_field'])) {
$sql_query = '
ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . '
ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field']));
if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
$sql_query .= ' DESC';
}
$message = PMA_DBI_query($sql_query) ? $strSuccess : $strError;
}
// end if
if ($reread_info) {
$checksum = $delay_key_write = 0;
require './libraries/tbl_info.inc.php';
}
unset($reread_info);
/**
* Displays top menu links
*/
require_once './libraries/tbl_links.inc.php';
$url_params['goto'] = 'tbl_operations.php';
$url_params['back'] = 'tbl_operations.php';
/**
* Get columns names
示例13: PMA_backquote
$message = $strDatabaseEmpty;
} else {
$local_query = 'CREATE DATABASE ' . PMA_backquote($newname) . ';';
$sql_query = $local_query;
PMA_DBI_query($local_query);
$tables = PMA_DBI_get_tables($db);
foreach ($tables as $table) {
$back = $sql_query;
$sql_query = '';
PMA_table_move_copy($db, $table, $newname, $table, isset($what) ? $what : 'data', $move);
$sql_query = $back . $sql_query;
}
if ($move) {
$local_query = 'DROP DATABASE ' . PMA_backquote($db) . ';';
$sql_query .= "\n" . $local_query;
PMA_DBI_query($local_query);
$message = sprintf($strRenameDatabaseOK, htmlspecialchars($db), htmlspecialchars($newname));
} else {
$message = sprintf($strCopyDatabaseOK, htmlspecialchars($db), htmlspecialchars($newname));
}
$reload = TRUE;
/* Change database to be used */
if ($move) {
$db = $newname;
} else {
$pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
if (isset($switch_to_new) && $switch_to_new == 'true') {
setcookie('pma_switch_to_new', 'true', 0, substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')), '', $pma_uri_parts['scheme'] == 'https');
$db = $newname;
} else {
setcookie('pma_switch_to_new', '', 0, substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')), '', $pma_uri_parts['scheme'] == 'https');
示例14: PMA_exportStructure
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $dummy)
{
global $cfgRelation;
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
$result = PMA_DBI_query($local_query);
$fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck)
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = TRUE;
} else {
$have_rel = FALSE;
}
} else {
$have_rel = FALSE;
}
// end if
/**
* Displays the table structure
*/
$buffer = $crlf . '%' . $crlf . '% ' . $GLOBALS['strStructure'] . ': ' . $table . $crlf . '%' . $crlf . ' \\begin{longtable}{';
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
$columns_cnt = 4;
$alignment = '|l|c|c|c|';
if ($do_relation && $have_rel) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_comments && ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100)) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
$alignment .= 'l|';
}
$buffer = $alignment . '} ' . $crlf;
$header = ' \\hline ';
$header .= '\\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strField'] . '}} & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strType'] . '}} & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strNull'] . '}} & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strDefault'] . '}}';
if ($do_relation && $have_rel) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strLinksTo'] . '}}';
}
if ($do_comments && ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100)) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strComments'] . '}}';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{MIME}}';
$mime_map = PMA_getMIME($db, $table, true);
}
$local_buffer = PMA_texEscape($table);
// Table caption for first page and label
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_structure_caption']) . '} \\label{' . str_replace('__TABLE__', $table, $GLOBALS['latex_structure_label']) . '} \\\\' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline' . $crlf . '\\endfirsthead' . $crlf;
// Table caption on next pages
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_structure_continued_caption']) . '} \\\\ ' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
while ($row = PMA_DBI_fetch_assoc($result)) {
$type = $row['Type'];
// reformat mysql query output - staybyte - 9. June 2001
// loic1: set or enum types: slashes single quotes inside options
if (eregi('^(set|enum)\\((.+)\\)$', $type, $tmp)) {
$tmp[2] = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = eregi_replace('BINARY', '', $type);
$type = eregi_replace('ZEROFILL', '', $type);
//.........这里部分代码省略.........
示例15: PMA_getDisplayField
//Set default datalabel if not selected
if (!isset($_POST['zoom_submit']) || $_POST['dataLabel'] == '') {
$dataLabel = PMA_getDisplayField($db, $table);
}
// Displays the zoom search form
$response->addHTML($table_search->getSelectionForm($goto, $dataLabel));
/*
* Handle the input criteria and generate the query result
* Form for displaying query results
*/
if (isset($zoom_submit) && $_POST['criteriaColumnNames'][0] != 'pma_null' && $_POST['criteriaColumnNames'][1] != 'pma_null' && $_POST['criteriaColumnNames'][0] != $_POST['criteriaColumnNames'][1]) {
//Query generation part
$sql_query = $table_search->buildSqlQuery();
$sql_query .= ' LIMIT ' . $maxPlotLimit;
//Query execution part
$result = PMA_DBI_query($sql_query . ";", null, PMA_DBI_QUERY_STORE);
$fields_meta = PMA_DBI_get_fields_meta($result);
while ($row = PMA_DBI_fetch_assoc($result)) {
//Need a row with indexes as 0,1,2 for the getUniqueCondition
// hence using a temporary array
$tmpRow = array();
foreach ($row as $val) {
$tmpRow[] = $val;
}
//Get unique conditon on each row (will be needed for row update)
$uniqueCondition = PMA_Util::getUniqueCondition($result, count($table_search->getColumnNames()), $fields_meta, $tmpRow, true);
//Append it to row array as where_clause
$row['where_clause'] = $uniqueCondition[0];
$tmpData = array($_POST['criteriaColumnNames'][0] => $row[$_POST['criteriaColumnNames'][0]], $_POST['criteriaColumnNames'][1] => $row[$_POST['criteriaColumnNames'][1]], 'where_clause' => $uniqueCondition[0]);
$tmpData[$dataLabel] = $dataLabel ? $row[$dataLabel] : '';
$data[] = $tmpData;