moved PMA_generateFieldSpec(), PMA_tableIsView(), PMA_countRecords(), PMA_generateAlterTable() into class PMA_Table

This commit is contained in:
Sebastian Mendel
2006-02-21 11:07:46 +00:00
parent 9515f39849
commit cd340d8496
12 changed files with 197 additions and 171 deletions

View File

@@ -11,8 +11,13 @@ $Source$
* libraries/Table.class.php: *NEW* class PMA_Table * libraries/Table.class.php: *NEW* class PMA_Table
* tbl_addfield.php, tbl_create.php: * tbl_addfield.php, tbl_create.php:
use Table.class.php use Table.class.php
* libraries/common.lib.php: * db_details_qbe.php, db_details_structure.php, tbl_alter.php, sql.php,
moved PMA_generateFieldSpec() into PMA_Table libraries/common.lib.php, libraries/tbl_properties_table_info.inc.php,
libraries/display_export.lib.php, libraries/display_tbl.lib.php,
libraries/get_foreign.lib.php, libraries/relation.lib.php:
moved PMA_generateFieldSpec(), PMA_tableIsView(), PMA_countRecords(),
PMA_generateAlterTable() into class PMA_Table
2006-02-20 Marc Delisle <lem9@users.sourceforge.net> 2006-02-20 Marc Delisle <lem9@users.sourceforge.net>
### 2.8.0-rc1 released ### 2.8.0-rc1 released

View File

@@ -10,6 +10,7 @@
* requirements * requirements
*/ */
require_once('./libraries/common.lib.php'); require_once('./libraries/common.lib.php');
require_once './libraries/Table.class.php';
require_once('./libraries/relation.lib.php'); require_once('./libraries/relation.lib.php');
@@ -805,7 +806,7 @@ if (isset($Field) && count($Field) > 0) {
$checked_tables = $col_cand; $checked_tables = $col_cand;
foreach ($col_cand AS $tab) { foreach ($col_cand AS $tab) {
if ($checked_tables[$tab] != 1 ) { if ($checked_tables[$tab] != 1 ) {
$tsize[$tab] = PMA_countRecords($db, $tab, true, false); $tsize[$tab] = PMA_Table::countRecords($db, $tab, true, false);
$checked_tables[$tab] = 1; $checked_tables[$tab] = 1;
} }
$csize[$tab] = $tsize[$tab]; $csize[$tab] = $tsize[$tab];

View File

@@ -3,6 +3,7 @@
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
require_once './libraries/common.lib.php'; require_once './libraries/common.lib.php';
require_once './libraries/Table.class.php';
/** /**
* Prepares the tables list if the user where not redirected to this script * Prepares the tables list if the user where not redirected to this script
@@ -175,7 +176,7 @@ $at_least_one_view_exceeds_max_count = false;
foreach ($tables as $keyname => $each_table) { foreach ($tables as $keyname => $each_table) {
if ($each_table['TABLE_ROWS'] === null || $each_table['TABLE_ROWS'] < $GLOBALS['cfg']['MaxExactCount']) { if ($each_table['TABLE_ROWS'] === null || $each_table['TABLE_ROWS'] < $GLOBALS['cfg']['MaxExactCount']) {
$each_table['TABLE_ROWS'] = PMA_countRecords($db, $each_table['TABLE_ROWS'] = PMA_Table::countRecords($db,
$each_table['TABLE_NAME'], $return = true, $force_exact = true); $each_table['TABLE_NAME'], $return = true, $force_exact = true);
} }

View File

@@ -110,8 +110,12 @@ class PMA_Table {
return $this->getDbName($quoted) . '.' . $this->getName($quoted); return $this->getDbName($quoted) . '.' . $this->getName($quoted);
} }
function isView() function isView($db = null, $table = null)
{ {
if (null !== $db && null !== $table) {
return PMA_Table::_isView($db, $table);
}
if ( strpos($this->get('TABLE TYPE'), 'VIEW') ) { if ( strpos($this->get('TABLE TYPE'), 'VIEW') ) {
return true; return true;
} }
@@ -161,7 +165,7 @@ class PMA_Table {
$this->settings = $table_info; $this->settings = $table_info;
if ( $this->get('TABLE_ROWS') === null ) { if ( $this->get('TABLE_ROWS') === null ) {
$this->set('TABLE_ROWS', PMA_countRecords($this->getDbName(), $this->set('TABLE_ROWS', PMA_Table::countRecords($this->getDbName(),
$this->getName(), true, true)); $this->getName(), true, true));
} }
@@ -187,6 +191,35 @@ class PMA_Table {
$this->__construct(); $this->__construct();
} }
/**
* Checks if this "table" is a view
*
* @deprecated
* @param string the database name
* @param string the table name
*
* @return boolean whether this is a view
*
* @access public
*/
function _isView($db, $table) {
// maybe we already know if the table is a view
// TODO: see what we could do with the possible existence
// of $table_is_view
if (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view']) {
return true;
}
// old MySQL version: no view
if (PMA_MYSQL_INT_VERSION < 50000) {
return false;
}
if ( false === PMA_DBI_fetch_value('SELECT TABLE_NAME FROM `information_schema`.`VIEWS` WHERE `TABLE_SCHEMA` = \'' . $db . '\' AND `TABLE_NAME` = \'' . $table . '\';')) {
return false;
} else {
return true;
}
}
/** /**
* @TODO add documentation * @TODO add documentation
* *
@@ -258,5 +291,75 @@ class PMA_Table {
return $query; return $query;
} // end function } // end function
/**
* Counts and returns (or displays) the number of records in a table
*
* Revision 13 July 2001: Patch for limiting dump size from
* vinay@sanisoft.com & girish@sanisoft.com
*
* @param string the current database name
* @param string the current table name
* @param boolean whether to retain or to displays the result
* @param boolean whether to force an exact count
*
* @return mixed the number of records if retain is required, true else
*
* @access public
*/
function countRecords($db, $table, $ret = false, $force_exact = false)
{
global $err_url, $cfg;
if (!$force_exact) {
$result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, true) . '\';');
$showtable = PMA_DBI_fetch_assoc($result);
$num = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
if ($num < $cfg['MaxExactCount']) {
unset($num);
}
PMA_DBI_free_result($result);
}
$tbl_is_view = PMA_Table::isView($db, $table);
if (!isset($num)) {
if (! $tbl_is_view) {
$num = PMA_DBI_fetch_value('SELECT COUNT(*) AS num FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
// necessary?
if (! $num) {
$num = 0;
}
// since counting all rows of a view could be too long
} else {
$result = PMA_DBI_query('SELECT 1 FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT ' . $cfg['MaxExactCount'], null, PMA_DBI_QUERY_STORE);
$num = PMA_DBI_num_rows($result);
}
}
if ($ret) {
return $num;
} else {
// Note: as of PMA 2.8.0, we no longer seem to be using
// PMA_Table::countRecords() in display mode.
echo number_format($num, 0, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator']);
if ($tbl_is_view) {
echo '&nbsp;' . sprintf($GLOBALS['strViewMaxExactCount'], $cfg['MaxExactCount'], '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]');
}
return true;
}
} // end of the 'PMA_Table::countRecords()' function
/**
* @TODO add documentation
*/
function generateAlter($oldcol, $newcol, $type, $length,
$attribute, $collation, $null, $default, $default_current_timestamp,
$extra, $comment='', $default_orig)
{
$empty_a = array();
return PMA_backquote($oldcol) . ' '
. PMA_generateFieldSpec($newcol, $type, $length, $attribute,
$collation, $null, $default, $default_current_timestamp, $extra,
$comment, $empty_a, -1, $default_orig);
} // end function
} }
?> ?>

View File

@@ -547,6 +547,7 @@ require_once './libraries/sanitizing.lib.php';
require_once './libraries/Theme.class.php'; require_once './libraries/Theme.class.php';
require_once './libraries/Theme_Manager.class.php'; require_once './libraries/Theme_Manager.class.php';
require_once './libraries/Config.class.php'; require_once './libraries/Config.class.php';
require_once './libraries/Table.class.php';
@@ -1147,14 +1148,14 @@ if (!defined('PMA_MINIMUM_COMMON')) {
// if row count is invalid possibly the table is defect // if row count is invalid possibly the table is defect
// and this would break left frame; // and this would break left frame;
// but we can check row count if this is a view, // but we can check row count if this is a view,
// since PMA_countRecords() returns a limited row count // since PMA_Table::countRecords() returns a limited row count
// in this case. // in this case.
// set this because PMA_countRecords() can use it // set this because PMA_Table::countRecords() can use it
$tbl_is_view = PMA_tableIsView($db, $table['Name']); $tbl_is_view = PMA_Table::isView($db, $table['Name']);
if ($tbl_is_view) { if ($tbl_is_view) {
$table['Rows'] = PMA_countRecords($db, $table['Name'], $table['Rows'] = PMA_Table::countRecords($db, $table['Name'],
$return = true); $return = true);
} }
} }
@@ -1311,90 +1312,6 @@ if (!defined('PMA_MINIMUM_COMMON')) {
return $the_crlf; return $the_crlf;
} // end of the 'PMA_whichCrlf()' function } // end of the 'PMA_whichCrlf()' function
/**
* Checks if this "table" is a view
*
* @param string the database name
* @param string the table name
*
* @return boolean whether this is a view
*
* @access public
*/
function PMA_tableIsView($db, $table) {
// maybe we already know if the table is a view
// TODO: see what we could do with the possible existence
// of $table_is_view
if (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view']) {
return true;
}
// old MySQL version: no view
if (PMA_MYSQL_INT_VERSION < 50000) {
return false;
}
if ( false === PMA_DBI_fetch_value('SELECT TABLE_NAME FROM information_schema.VIEWS WHERE TABLE_SCHEMA = \'' . $db . '\' AND TABLE_NAME = \'' . $table . '\';')) {
return false;
} else {
return true;
}
}
/**
* Counts and returns (or displays) the number of records in a table
*
* Revision 13 July 2001: Patch for limiting dump size from
* vinay@sanisoft.com & girish@sanisoft.com
*
* @param string the current database name
* @param string the current table name
* @param boolean whether to retain or to displays the result
* @param boolean whether to force an exact count
*
* @return mixed the number of records if retain is required, true else
*
* @access public
*/
function PMA_countRecords($db, $table, $ret = false, $force_exact = false)
{
global $err_url, $cfg;
if (!$force_exact) {
$result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, true) . '\';');
$showtable = PMA_DBI_fetch_assoc($result);
$num = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
if ($num < $cfg['MaxExactCount']) {
unset($num);
}
PMA_DBI_free_result($result);
}
$tbl_is_view = PMA_tableIsView($db, $table);
if (!isset($num)) {
if (! $tbl_is_view) {
$num = PMA_DBI_fetch_value('SELECT COUNT(*) AS num FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
// necessary?
if (! $num) {
$num = 0;
}
// since counting all rows of a view could be too long
} else {
$result = PMA_DBI_query('SELECT 1 FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT ' . $cfg['MaxExactCount'], null, PMA_DBI_QUERY_STORE);
$num = PMA_DBI_num_rows($result);
}
}
if ($ret) {
return $num;
} else {
// Note: as of PMA 2.8.0, we no longer seem to be using
// PMA_countRecords() in display mode.
echo number_format($num, 0, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator']);
if ($tbl_is_view) {
echo '&nbsp;' . sprintf($GLOBALS['strViewMaxExactCount'], $cfg['MaxExactCount'], '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]');
}
return true;
}
} // end of the 'PMA_countRecords()' function
/** /**
* Reloads navigation if needed. * Reloads navigation if needed.
* *
@@ -2505,20 +2422,6 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
return $gotopage; return $gotopage;
} // end function } // end function
/**
* @TODO add documentation
*/
function PMA_generateAlterTable($oldcol, $newcol, $type, $length,
$attribute, $collation, $null, $default, $default_current_timestamp,
$extra, $comment='', $default_orig)
{
$empty_a = array();
return PMA_backquote($oldcol) . ' '
. PMA_generateFieldSpec($newcol, $type, $length, $attribute,
$collation, $null, $default, $default_current_timestamp, $extra,
$comment, $empty_a, -1, $default_orig);
} // end function
/** /**
* @TODO add documentation * @TODO add documentation
*/ */

View File

@@ -2,6 +2,8 @@
/* $Id$ */ /* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
require_once './libraries/Table.class.php';
// Get relations & co. status // Get relations & co. status
require_once('./libraries/relation.lib.php'); require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam(); $cfgRelation = PMA_getRelationsParam();
@@ -774,7 +776,7 @@ function show_checked_option() {
<?php <?php
echo sprintf( $strDumpXRows, echo sprintf( $strDumpXRows,
'<input type="text" name="limit_to" size="5" value="' '<input type="text" name="limit_to" size="5" value="'
. ( isset( $unlim_num_rows ) ? $unlim_num_rows : PMA_countRecords( $db, $table, TRUE ) ) . ( isset( $unlim_num_rows ) ? $unlim_num_rows : PMA_Table::countRecords( $db, $table, TRUE ) )
. '" onfocus="this.select()" />', . '" onfocus="this.select()" />',
'<input type="text" name="limit_from" value="0" size="5"' '<input type="text" name="limit_from" value="0" size="5"'
.' onfocus="this.select()" /> '); .' onfocus="this.select()" /> ');

View File

@@ -2,6 +2,8 @@
/* $Id$ */ /* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
require_once './libraries/Table.class.php';
/** /**
* Set of functions used to display the records returned by a sql query * Set of functions used to display the records returned by a sql query
*/ */
@@ -72,7 +74,7 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
// 2. Display mode is not "false for all elements" -> updates the // 2. Display mode is not "false for all elements" -> updates the
// display mode // display mode
if ($the_disp_mode != 'nnnn000000') { if ($the_disp_mode != 'nnnn000000') {
// 2.0 Print view -> set all elements to FALSE! // 2.0 Print view -> set all elements to false!
if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') { if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
$do_display['edit_lnk'] = 'nn'; // no edit link $do_display['edit_lnk'] = 'nn'; // no edit link
$do_display['del_lnk'] = 'nn'; // no delete link $do_display['del_lnk'] = 'nn'; // no delete link
@@ -156,7 +158,7 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
$the_total = $unlim_num_rows; $the_total = $unlim_num_rows;
} elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') } elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
&& (isset($db) && strlen($db) && !empty($table))) { && (isset($db) && strlen($db) && !empty($table))) {
$the_total = PMA_countRecords($db, $table, TRUE); $the_total = PMA_Table::countRecords($db, $table, true);
} }
// 4. If navigation bar or sorting fields names urls should be // 4. If navigation bar or sorting fields names urls should be
@@ -344,7 +346,7 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_query)
if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) { if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) {
echo '<input type="hidden" name="find_real_end" value="1" />' . "\n"; echo '<input type="hidden" name="find_real_end" value="1" />' . "\n";
// no backquote around this message // no backquote around this message
$onclick = ' onclick="return confirmAction(\'' . PMA_jsFormat($GLOBALS['strLongOperation'], FALSE) . '\')"'; $onclick = ' onclick="return confirmAction(\'' . PMA_jsFormat($GLOBALS['strLongOperation'], false) . '\')"';
} }
?> ?>
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" /> <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
@@ -495,7 +497,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
$prev_index = ''; $prev_index = '';
foreach ($ret_keys as $row) { foreach ($ret_keys as $row) {
if ($row['Key_name'] != $prev_index ){ if ($row['Key_name'] != $prev_index){
$indexes[] = $row['Key_name']; $indexes[] = $row['Key_name'];
$prev_index = $row['Key_name']; $prev_index = $row['Key_name'];
} }
@@ -562,7 +564,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $desc_sort) . '"' . ($local_order == $desc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strDescending'] . ')</option>'; echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $desc_sort) . '"' . ($local_order == $desc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strDescending'] . ')</option>';
echo "\n"; echo "\n";
} }
echo '<option value="' . htmlspecialchars($unsorted_sql_query) . '"' . ($used_index ? '' : ' selected="selected"' ) . '>' . $GLOBALS['strNone'] . '</option>'; echo '<option value="' . htmlspecialchars($unsorted_sql_query) . '"' . ($used_index ? '' : ' selected="selected"') . '>' . $GLOBALS['strNone'] . '</option>';
echo "\n"; echo "\n";
echo '</select>' . "\n"; echo '</select>' . "\n";
echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />'; echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
@@ -580,7 +582,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// Start of form for multi-rows delete // Start of form for multi-rows delete
if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp' ) { if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp') {
echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm" id="rowsDeleteForm">' . "\n"; echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm" id="rowsDeleteForm">' . "\n";
echo PMA_generate_common_hidden_inputs($db, $table, 1); echo PMA_generate_common_hidden_inputs($db, $table, 1);
echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n"; echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
@@ -616,7 +618,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
. '&amp;goto=' . $goto . '&amp;goto=' . $goto
. '&amp;dontlimitchars=' . (($dontlimitchars) ? 0 : 1); . '&amp;dontlimitchars=' . (($dontlimitchars) ? 0 : 1);
$text_message = '<img class="fulltext" src="' . $GLOBALS['pmaThemeImage'] . 's_'.($dontlimitchars ? 'partialtext' : 'fulltext') . '.png" width="50" height="20" alt="' . ($dontlimitchars ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" title="' . ($dontlimitchars ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" />'; $text_message = '<img class="fulltext" src="' . $GLOBALS['pmaThemeImage'] . 's_'.($dontlimitchars ? 'partialtext' : 'fulltext') . '.png" width="50" height="20" alt="' . ($dontlimitchars ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" title="' . ($dontlimitchars ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" />';
$text_link = PMA_linkOrButton( $text_url, $text_message, array(), false ); $text_link = PMA_linkOrButton($text_url, $text_message, array(), false);
// ... before the result table // ... before the result table
if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn') if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
@@ -687,16 +689,16 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
} }
if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) { if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
require_once('./libraries/transformations.lib.php'); require_once './libraries/transformations.lib.php';
$GLOBALS['mime_map'] = PMA_getMIME($db, $table); $GLOBALS['mime_map'] = PMA_getMIME($db, $table);
} }
if ($is_display['sort_lnk'] == '1') { if ($is_display['sort_lnk'] == '1') {
//$is_join = preg_match('@(.*)[[:space:]]+FROM[[:space:]]+.*[[:space:]]+JOIN@im', $sql_query, $select_stt); //$is_join = preg_match('@(.*)[[:space:]]+FROM[[:space:]]+.*[[:space:]]+JOIN@im', $sql_query, $select_stt);
$is_join = (isset($analyzed_sql[0]['queryflags']['join']) ?TRUE:FALSE); $is_join = (isset($analyzed_sql[0]['queryflags']['join']) ? true : false);
$select_expr = $analyzed_sql[0]['select_expr_clause']; $select_expr = $analyzed_sql[0]['select_expr_clause'];
} else { } else {
$is_join = FALSE; $is_join = false;
} }
// garvin: See if we have to highlight any header fields of a WHERE query. // garvin: See if we have to highlight any header fields of a WHERE query.
@@ -742,11 +744,11 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
if (($is_join if (($is_join
&& !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . strtr($fields_meta[$i]->name, array('[' => '\\[', '~' => '\\~', '\\' => '\\\\')) . '~i', $select_expr, $parts)) && !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . strtr($fields_meta[$i]->name, array('[' => '\\[', '~' => '\\~', '\\' => '\\\\')) . '~i', $select_expr, $parts))
|| ( isset($analyzed_sql[0]['select_expr'][$i]['expr']) || (isset($analyzed_sql[0]['select_expr'][$i]['expr'])
&& isset($analyzed_sql[0]['select_expr'][$i]['column']) && isset($analyzed_sql[0]['select_expr'][$i]['column'])
&& $analyzed_sql[0]['select_expr'][$i]['expr'] != && $analyzed_sql[0]['select_expr'][$i]['expr'] !=
$analyzed_sql[0]['select_expr'][$i]['column'] $analyzed_sql[0]['select_expr'][$i]['column']
&& isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table)) ) { && isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table))) {
$sort_tbl = PMA_backquote($fields_meta[$i]->table) . ' . '; $sort_tbl = PMA_backquote($fields_meta[$i]->table) . ' . ';
} else { } else {
$sort_tbl = ''; $sort_tbl = '';
@@ -754,15 +756,15 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// 2.1.2 Checks if the current column is used to sort the // 2.1.2 Checks if the current column is used to sort the
// results // results
if (empty($sort_expression)) { if (empty($sort_expression)) {
$is_in_sort = FALSE; $is_in_sort = false;
} else { } else {
// field name may be preceded by a space, or any number // field name may be preceded by a space, or any number
// of characters followed by a dot (tablename.fieldname) // of characters followed by a dot (tablename.fieldname)
// so do a direct comparison // so do a direct comparison
// for the sort expression (avoids problems with queries // for the sort expression (avoids problems with queries
// like "SELECT id, count(id)..." and clicking to sort // like "SELECT id, count(id)..." and clicking to sort
// on id or on count(id) ) // on id or on count(id))
$is_in_sort = ($sort_tbl . PMA_backquote($fields_meta[$i]->name) == $sort_expression_nodir ? TRUE : FALSE); $is_in_sort = ($sort_tbl . PMA_backquote($fields_meta[$i]->name) == $sort_expression_nodir ? true : false);
} }
// 2.1.3 Check the field name for backquotes. // 2.1.3 Check the field name for backquotes.
// If it contains some, it's probably a function column // If it contains some, it's probably a function column
@@ -820,13 +822,13 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
$order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }'; $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
} }
} }
if ( $disp_direction == 'horizontalflipped' if ($disp_direction == 'horizontalflipped'
&& $GLOBALS['cfg']['HeaderFlipType'] == 'css' ) { && $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
$order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;'; $order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;';
} }
$order_link_params['title'] = $GLOBALS['strSort']; $order_link_params['title'] = $GLOBALS['strSort'];
$order_link_content = ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name)); $order_link_content = ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name));
$order_link = PMA_linkOrButton( $order_url, $order_link_content . $order_img, $order_link_params, false, true ); $order_link = PMA_linkOrButton($order_url, $order_link_content . $order_img, $order_link_params, false, true);
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
?> ?>
@@ -904,7 +906,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
<?php <?php
} }
return TRUE; return true;
} // end of the 'PMA_displayTableHeaders()' function } // end of the 'PMA_displayTableHeaders()' function
@@ -1002,21 +1004,21 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$odd_row = true; $odd_row = true;
while ($row = PMA_DBI_fetch_row($dt_result)) { while ($row = PMA_DBI_fetch_row($dt_result)) {
// lem9: "vertical display" mode stuff // lem9: "vertical display" mode stuff
if ( $row_no != 0 && $repeat_cells != 0 && !($row_no % $repeat_cells) if ($row_no != 0 && $repeat_cells != 0 && !($row_no % $repeat_cells)
&& ( $disp_direction == 'horizontal' && ($disp_direction == 'horizontal'
|| $disp_direction == 'horizontalflipped') ) || $disp_direction == 'horizontalflipped'))
{ {
echo '<tr>' . "\n"; echo '<tr>' . "\n";
if ( $vertical_display['emptypre'] > 0 ) { if ($vertical_display['emptypre'] > 0) {
echo ' <th colspan="' . $vertical_display['emptypre'] . '">' . "\n" echo ' <th colspan="' . $vertical_display['emptypre'] . '">' . "\n"
.' &nbsp;</th>' . "\n"; .' &nbsp;</th>' . "\n";
} }
foreach ( $vertical_display['desc'] as $val ) { foreach ($vertical_display['desc'] as $val) {
echo $val; echo $val;
} }
if ( $vertical_display['emptyafter'] > 0 ) { if ($vertical_display['emptyafter'] > 0) {
echo ' <th colspan="' . $vertical_display['emptyafter'] . '">' . "\n" echo ' <th colspan="' . $vertical_display['emptyafter'] . '">' . "\n"
.' &nbsp;</th>' . "\n"; .' &nbsp;</th>' . "\n";
} }
@@ -1025,13 +1027,13 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
// loic1: pointer code part // loic1: pointer code part
echo ' <tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n"; echo ' <tr class="' . ($odd_row ? 'odd' : 'even') . '">' . "\n";
$odd_row = ! $odd_row; $odd_row = ! $odd_row;
$bgcolor = ''; $bgcolor = '';
} elseif (isset($GLOBALS['printview']) && ($GLOBALS['printview'] == '1')) { } elseif (isset($GLOBALS['printview']) && ($GLOBALS['printview'] == '1')) {
$bgcolor = ' bgcolor="#ffffff" '; $bgcolor = ' bgcolor="#ffffff" ';
} else { } else {
$bgcolor = ' bgcolor="' . ($row_no % 2 ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'] ) . '" '; $bgcolor = ' bgcolor="' . ($row_no % 2 ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']) . '" ';
} }
@@ -1066,7 +1068,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
. '&amp;primary_key=' . $uva_condition . '&amp;primary_key=' . $uva_condition
. '&amp;sql_query=' . urlencode($url_sql_query) . '&amp;sql_query=' . urlencode($url_sql_query)
. '&amp;goto=' . urlencode($lnk_goto); . '&amp;goto=' . urlencode($lnk_goto);
if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) { if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
$edit_str = $GLOBALS['strEdit']; $edit_str = $GLOBALS['strEdit'];
} else { } else {
$edit_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" alt="' . $GLOBALS['strEdit'] . '" title="' . $GLOBALS['strEdit'] . '" />'; $edit_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" alt="' . $GLOBALS['strEdit'] . '" title="' . $GLOBALS['strEdit'] . '" />';
@@ -1085,7 +1087,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
. '&amp;SQL=' . $GLOBALS['strExecuteBookmarked'] . '&amp;SQL=' . $GLOBALS['strExecuteBookmarked']
.' " title="' . $GLOBALS['strExecuteBookmarked'] . '">'; .' " title="' . $GLOBALS['strExecuteBookmarked'] . '">';
if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) { if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
$bookmark_go .= $GLOBALS['strExecuteBookmarked']; $bookmark_go .= $GLOBALS['strExecuteBookmarked'];
} else { } else {
$bookmark_go .= $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_bookmark.png" alt="' . $GLOBALS['strExecuteBookmarked'] . '" title="' . $GLOBALS['strExecuteBookmarked'] . '" />'; $bookmark_go .= $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_bookmark.png" alt="' . $GLOBALS['strExecuteBookmarked'] . '" title="' . $GLOBALS['strExecuteBookmarked'] . '" />';
@@ -1113,9 +1115,9 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
. '&amp;zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&amp;zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
. '&amp;goto=' . urlencode($lnk_goto); . '&amp;goto=' . urlencode($lnk_goto);
$js_conf = 'DELETE FROM ' . PMA_jsFormat($table) $js_conf = 'DELETE FROM ' . PMA_jsFormat($table)
. ' WHERE ' . trim(PMA_jsFormat(urldecode($uva_condition), FALSE)) . ' WHERE ' . trim(PMA_jsFormat(urldecode($uva_condition), false))
. ' LIMIT 1'; . ' LIMIT 1';
if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) { if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
$del_str = $GLOBALS['strDelete']; $del_str = $GLOBALS['strDelete'];
} else { } else {
$del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strDelete'] . '" title="' . $GLOBALS['strDelete'] . '" />'; $del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strDelete'] . '" title="' . $GLOBALS['strDelete'] . '" />';
@@ -1134,7 +1136,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
. '&amp;goto=' . urlencode($lnk_goto); . '&amp;goto=' . urlencode($lnk_goto);
$del_query = urlencode('KILL ' . $row[0]); $del_query = urlencode('KILL ' . $row[0]);
$js_conf = 'KILL ' . $row[0]; $js_conf = 'KILL ' . $row[0];
if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) { if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
$del_str = $GLOBALS['strKill']; $del_str = $GLOBALS['strKill'];
} else { } else {
$del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strKill'] . '" title="' . $GLOBALS['strKill'] . '" />'; $del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strKill'] . '" title="' . $GLOBALS['strKill'] . '" />';
@@ -1148,7 +1150,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] if ($GLOBALS['cfg']['ModifyDeleteAtLeft']
&& ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) { && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
$doWriteModifyAt = 'left'; $doWriteModifyAt = 'left';
require('./libraries/display_tbl_links.lib.php'); require './libraries/display_tbl_links.lib.php';
} // end if (1.3) } // end if (1.3)
} // end if (1) } // end if (1)
@@ -1168,11 +1170,11 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
} }
if ($disp_direction == 'vertical' && (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1'))) { if ($disp_direction == 'vertical' && (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1'))) {
if ($GLOBALS['cfg']['BrowsePointerColor'] == TRUE) { if ($GLOBALS['cfg']['BrowsePointerColor'] == true) {
$column_style .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"' $column_style .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
. ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');" '; . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');" ';
} }
if ($GLOBALS['cfg']['BrowseMarkerEnable'] == TRUE) { if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) {
$column_style .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\'); setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" '; $column_style .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\'); setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
} else { } else {
$column_style .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" '; $column_style .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
@@ -1192,7 +1194,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
if (file_exists('./libraries/transformations/' . $include_file)) { if (file_exists('./libraries/transformations/' . $include_file)) {
$transformfunction_name = preg_replace('@(\.inc\.php3?)$@i', '', $GLOBALS['mime_map'][$meta->name]['transformation']); $transformfunction_name = preg_replace('@(\.inc\.php3?)$@i', '', $GLOBALS['mime_map'][$meta->name]['transformation']);
require_once('./libraries/transformations/' . $include_file); require_once './libraries/transformations/' . $include_file;
if (function_exists('PMA_transformation_' . $transformfunction_name)) { if (function_exists('PMA_transformation_' . $transformfunction_name)) {
$transform_function = 'PMA_transformation_' . $transformfunction_name; $transform_function = 'PMA_transformation_' . $transformfunction_name;
@@ -1282,7 +1284,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// b l o b // b l o b
} elseif ($GLOBALS['cfg']['ShowBlob'] == FALSE && stristr($meta->type, 'BLOB')) { } elseif ($GLOBALS['cfg']['ShowBlob'] == false && stristr($meta->type, 'BLOB')) {
// loic1 : PMA_mysql_fetch_fields returns BLOB in place of // loic1 : PMA_mysql_fetch_fields returns BLOB in place of
// TEXT fields type, however TEXT fields must be displayed // TEXT fields type, however TEXT fields must be displayed
// even if $GLOBALS['cfg']['ShowBlob'] is false -> get the true type // even if $GLOBALS['cfg']['ShowBlob'] is false -> get the true type
@@ -1416,7 +1418,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
if ($GLOBALS['cfg']['ModifyDeleteAtRight'] if ($GLOBALS['cfg']['ModifyDeleteAtRight']
&& ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) { && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
$doWriteModifyAt = 'right'; $doWriteModifyAt = 'right';
require('./libraries/display_tbl_links.lib.php'); require './libraries/display_tbl_links.lib.php';
} // end if (3) } // end if (3)
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
@@ -1434,12 +1436,12 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
} }
$column_style_vertical = ''; $column_style_vertical = '';
if ($GLOBALS['cfg']['BrowsePointerEnable'] == TRUE) { if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) {
$column_style_vertical .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"' $column_style_vertical .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
. ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'; . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
} }
$column_marker_vertical = ''; $column_marker_vertical = '';
if ($GLOBALS['cfg']['BrowseMarkerEnable'] == TRUE) { if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) {
$column_marker_vertical .= 'setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');'; $column_marker_vertical .= 'setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');';
} }
@@ -1455,7 +1457,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
if (isset($edit_url)) { if (isset($edit_url)) {
$vertical_display['edit'][$row_no] .= ' <td align="center"' . $bgcolor . $column_style_vertical . '>' . "\n" $vertical_display['edit'][$row_no] .= ' <td align="center"' . $bgcolor . $column_style_vertical . '>' . "\n"
. PMA_linkOrButton($edit_url, $edit_str, array(), FALSE) . PMA_linkOrButton($edit_url, $edit_str, array(), false)
. $bookmark_go . $bookmark_go
. ' </td>' . "\n"; . ' </td>' . "\n";
} else { } else {
@@ -1464,7 +1466,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
if (isset($del_url)) { if (isset($del_url)) {
$vertical_display['delete'][$row_no] .= ' <td align="center"' . $bgcolor . $column_style_vertical . '>' . "\n" $vertical_display['delete'][$row_no] .= ' <td align="center"' . $bgcolor . $column_style_vertical . '>' . "\n"
. PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), FALSE) . PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), false)
. ' </td>' . "\n"; . ' </td>' . "\n";
} else { } else {
unset($vertical_display['delete'][$row_no]); unset($vertical_display['delete'][$row_no]);
@@ -1478,7 +1480,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$GLOBALS['url_query'] = $url_query; $GLOBALS['url_query'] = $url_query;
} }
return TRUE; return true;
} // end of the 'PMA_displayTableBody()' function } // end of the 'PMA_displayTableBody()' function
@@ -1623,7 +1625,7 @@ function PMA_displayVerticalTable()
echo '</tr>' . "\n"; echo '</tr>' . "\n";
} }
return TRUE; return true;
} // end of the 'PMA_displayVerticalTable' function } // end of the 'PMA_displayVerticalTable' function
@@ -1716,8 +1718,8 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
$last_shown_rec = ($GLOBALS['session_max_rows'] == 'all' || $pos_next > $total) $last_shown_rec = ($GLOBALS['session_max_rows'] == 'all' || $pos_next > $total)
? $total - 1 ? $total - 1
: $pos_next - 1; : $pos_next - 1;
PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec (" . PMA_formatNumber( $total, 0 ) . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')'); PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec (" . PMA_formatNumber($total, 0) . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
if (PMA_tableIsView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCount']) { if (PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCount']) {
echo '<div class="notice">' . "\n"; echo '<div class="notice">' . "\n";
echo PMA_sanitize(sprintf($GLOBALS['strViewMaxExactCount'], PMA_formatNumber($GLOBALS['cfg']['MaxExactCount'], 0), '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]')) . "\n"; echo PMA_sanitize(sprintf($GLOBALS['strViewMaxExactCount'], PMA_formatNumber($GLOBALS['cfg']['MaxExactCount'], 0), '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]')) . "\n";
echo '</div>' . "\n"; echo '</div>' . "\n";
@@ -1763,7 +1765,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
if ($cfgRelation['displaywork']) { if ($cfgRelation['displaywork']) {
if (! isset($table) || ! strlen($table)) { if (! isset($table) || ! strlen($table)) {
$exist_rel = FALSE; $exist_rel = false;
} else { } else {
$exist_rel = PMA_getForeigners($db, $table, '', 'both'); $exist_rel = PMA_getForeigners($db, $table, '', 'both');
if ($exist_rel) { if ($exist_rel) {
@@ -1812,16 +1814,16 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
. '&amp;dontlimitchars=' . $dontlimitchars; . '&amp;dontlimitchars=' . $dontlimitchars;
$checkall_url = $uncheckall_url . '&amp;checkall=1'; $checkall_url = $uncheckall_url . '&amp;checkall=1';
if ( $disp_direction == 'vertical' ) { if ($disp_direction == 'vertical') {
$checkall_params['onclick'] = 'if ( setCheckboxes(\'rowsDeleteForm\', true) ) return false;'; $checkall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', true)) return false;';
$uncheckall_params['onclick'] = 'if ( setCheckboxes(\'rowsDeleteForm\', false) ) return false;'; $uncheckall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', false)) return false;';
} else { } else {
$checkall_params['onclick'] = 'if ( markAllRows(\'rowsDeleteForm\') ) return false;'; $checkall_params['onclick'] = 'if (markAllRows(\'rowsDeleteForm\')) return false;';
$uncheckall_params['onclick'] = 'if ( unMarkAllRows(\'rowsDeleteForm\') ) return false;'; $uncheckall_params['onclick'] = 'if (unMarkAllRows(\'rowsDeleteForm\')) return false;';
} }
$checkall_link = PMA_linkOrButton( $checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false ); $checkall_link = PMA_linkOrButton($checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false);
$uncheckall_link = PMA_linkOrButton( $uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false ); $uncheckall_link = PMA_linkOrButton($uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false);
if ( $disp_direction != 'vertical' ) { if ($disp_direction != 'vertical') {
echo '<img class="selectallarrow" width="38" height="22"' echo '<img class="selectallarrow" width="38" height="22"'
.' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"' .' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"'
.' alt="' . $GLOBALS['strWithChecked'] . '" />'; .' alt="' . $GLOBALS['strWithChecked'] . '" />';
@@ -1831,7 +1833,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
.$uncheckall_link . "\n" .$uncheckall_link . "\n"
.'<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n"; .'<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n";
if ( $GLOBALS['cfg']['PropertiesIconic'] ) { if ($GLOBALS['cfg']['PropertiesIconic']) {
PMA_buttonOrImage('submit_mult', 'mult_submit', PMA_buttonOrImage('submit_mult', 'mult_submit',
'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png'); 'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png');
PMA_buttonOrImage('submit_mult', 'mult_submit', PMA_buttonOrImage('submit_mult', 'mult_submit',

View File

@@ -3,6 +3,8 @@
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
require_once './libraries/Table.class.php';
/** /**
* Gets foreign keys in preparation for a drop-down selector * Gets foreign keys in preparation for a drop-down selector
* Thanks to <markus@noga.de> * Thanks to <markus@noga.de>
@@ -25,7 +27,7 @@ if ($foreigners && isset($foreigners[$field])) {
// We could also do the SELECT anyway, with a LIMIT, and ensure that // We could also do the SELECT anyway, with a LIMIT, and ensure that
// the current value of the field is one of the choices. // the current value of the field is one of the choices.
$the_total = PMA_countRecords($foreign_db, $foreign_table, TRUE); $the_total = PMA_Table::countRecords($foreign_db, $foreign_table, TRUE);
if ((isset($override_total) && $override_total == true) || $the_total < $cfg['ForeignKeyMaxLimit']) { if ((isset($override_total) && $override_total == true) || $the_total < $cfg['ForeignKeyMaxLimit']) {
// foreign_display can be FALSE if no display field defined: // foreign_display can be FALSE if no display field defined:

View File

@@ -2,6 +2,8 @@
/* $Id$ */ /* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
require_once './libraries/Table.class.php';
/** /**
* Set of functions used with the relation and pdf feature * Set of functions used with the relation and pdf feature
*/ */
@@ -582,7 +584,7 @@ function PMA_setComment($db, $table, $col, $comment, $removekey = '', $mode='aut
// native mode is only for column comments so we need a table name // native mode is only for column comments so we need a table name
if ($mode == 'native' && isset($table) && strlen($table)) { if ($mode == 'native' && isset($table) && strlen($table)) {
$query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE ' $query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE '
. PMA_generateAlterTable($col, $col, '', '', '', '', FALSE, '', FALSE, '', $comment, '', ''); . PMA_Table::generateAlter($col, $col, '', '', '', '', FALSE, '', FALSE, '', $comment, '', '');
PMA_DBI_try_query($query, null, PMA_DBI_QUERY_STORE); PMA_DBI_try_query($query, null, PMA_DBI_QUERY_STORE);
return TRUE; return TRUE;
} }

View File

@@ -2,6 +2,8 @@
/* $Id$ */ /* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
require_once './libraries/Table.class.php';
/** /**
* extracts table properties from create statement * extracts table properties from create statement
* *
@@ -75,7 +77,7 @@ if ($table_info_result && PMA_DBI_num_rows($table_info_result) > 0) {
: $showtable['Collation']; : $showtable['Collation'];
if ( null === $showtable['Rows'] ) { if ( null === $showtable['Rows'] ) {
$showtable['Rows'] = PMA_countRecords( $GLOBALS['db'], $showtable['Rows'] = PMA_Table::countRecords( $GLOBALS['db'],
$showtable['Name'], true, true ); $showtable['Name'], true, true );
} }
$table_info_num_rows = isset($showtable['Rows']) ? $showtable['Rows'] : 0; $table_info_num_rows = isset($showtable['Rows']) ? $showtable['Rows'] : 0;

View File

@@ -6,6 +6,7 @@
* Gets some core libraries * Gets some core libraries
*/ */
require_once './libraries/common.lib.php'; require_once './libraries/common.lib.php';
require_once './libraries/Table.class.php';
require_once './libraries/tbl_indexes.lib.php'; require_once './libraries/tbl_indexes.lib.php';
require_once './libraries/check_user_privileges.lib.php'; require_once './libraries/check_user_privileges.lib.php';
require_once './libraries/bookmark.lib.php'; require_once './libraries/bookmark.lib.php';
@@ -83,7 +84,7 @@ if (!defined('PMA_CHK_DROP')
*/ */
if (isset($find_real_end) && $find_real_end) { if (isset($find_real_end) && $find_real_end) {
$unlim_num_rows = PMA_countRecords($db, $table, true, true); $unlim_num_rows = PMA_Table::countRecords($db, $table, true, true);
$pos = @((ceil($unlim_num_rows / $session_max_rows) - 1) * $session_max_rows); $pos = @((ceil($unlim_num_rows / $session_max_rows) - 1) * $session_max_rows);
} }
/** /**
@@ -453,7 +454,7 @@ else {
) { ) {
// "j u s t b r o w s i n g" // "j u s t b r o w s i n g"
$unlim_num_rows = PMA_countRecords($db, $table, true); $unlim_num_rows = PMA_Table::countRecords($db, $table, true);
} else { // n o t " j u s t b r o w s i n g " } else { // n o t " j u s t b r o w s i n g "

View File

@@ -2,6 +2,8 @@
/* $Id$ */ /* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
require_once './libraries/Table.class.php';
/** /**
* Gets some core libraries * Gets some core libraries
*/ */
@@ -58,7 +60,7 @@ if (isset($do_save_data)) {
$query .= ', CHANGE '; $query .= ', CHANGE ';
} }
$query .= PMA_generateAlterTable($field_orig[$i], $field_name[$i], $field_type[$i], $field_length[$i], $field_attribute[$i], isset($field_collation[$i]) ? $field_collation[$i] : '', $field_null[$i], $field_default[$i], isset($field_default_current_timestamp[$i]), $field_extra[$i], (isset($field_comments[$i]) ? $field_comments[$i] : ''), $field_default_orig[$i]); $query .= PMA_Table::generateAlter($field_orig[$i], $field_name[$i], $field_type[$i], $field_length[$i], $field_attribute[$i], isset($field_collation[$i]) ? $field_collation[$i] : '', $field_null[$i], $field_default[$i], isset($field_default_current_timestamp[$i]), $field_extra[$i], (isset($field_comments[$i]) ? $field_comments[$i] : ''), $field_default_orig[$i]);
} // end for } // end for
// To allow replication, we first select the db to use and then run queries // To allow replication, we first select the db to use and then run queries