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
* tbl_addfield.php, tbl_create.php:
use Table.class.php
* libraries/common.lib.php:
moved PMA_generateFieldSpec() into PMA_Table
* db_details_qbe.php, db_details_structure.php, tbl_alter.php, sql.php,
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>
### 2.8.0-rc1 released

View File

@@ -10,6 +10,7 @@
* requirements
*/
require_once('./libraries/common.lib.php');
require_once './libraries/Table.class.php';
require_once('./libraries/relation.lib.php');
@@ -805,7 +806,7 @@ if (isset($Field) && count($Field) > 0) {
$checked_tables = $col_cand;
foreach ($col_cand AS $tab) {
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;
}
$csize[$tab] = $tsize[$tab];

View File

@@ -3,6 +3,7 @@
// vim: expandtab sw=4 ts=4 sts=4:
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
@@ -175,7 +176,7 @@ $at_least_one_view_exceeds_max_count = false;
foreach ($tables as $keyname => $each_table) {
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);
}

View File

@@ -110,8 +110,12 @@ class PMA_Table {
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') ) {
return true;
}
@@ -161,7 +165,7 @@ class PMA_Table {
$this->settings = $table_info;
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));
}
@@ -187,6 +191,35 @@ class PMA_Table {
$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
*
@@ -258,5 +291,75 @@ class PMA_Table {
return $query;
} // 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_Manager.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
// and this would break left frame;
// 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.
// set this because PMA_countRecords() can use it
$tbl_is_view = PMA_tableIsView($db, $table['Name']);
// set this because PMA_Table::countRecords() can use it
$tbl_is_view = PMA_Table::isView($db, $table['Name']);
if ($tbl_is_view) {
$table['Rows'] = PMA_countRecords($db, $table['Name'],
$table['Rows'] = PMA_Table::countRecords($db, $table['Name'],
$return = true);
}
}
@@ -1311,90 +1312,6 @@ if (!defined('PMA_MINIMUM_COMMON')) {
return $the_crlf;
} // 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.
*
@@ -2505,20 +2422,6 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
return $gotopage;
} // 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
*/

View File

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

View File

@@ -2,6 +2,8 @@
/* $Id$ */
// 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
*/
@@ -72,7 +74,7 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
// 2. Display mode is not "false for all elements" -> updates the
// display mode
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') {
$do_display['edit_lnk'] = 'nn'; // no edit 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;
} elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
&& (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
@@ -344,7 +346,7 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_query)
if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) {
echo '<input type="hidden" name="find_real_end" value="1" />' . "\n";
// 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; ?>" />
@@ -687,16 +689,16 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
}
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);
}
if ($is_display['sort_lnk'] == '1') {
//$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'];
} else {
$is_join = FALSE;
$is_join = false;
}
// garvin: See if we have to highlight any header fields of a WHERE query.
@@ -754,7 +756,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// 2.1.2 Checks if the current column is used to sort the
// results
if (empty($sort_expression)) {
$is_in_sort = FALSE;
$is_in_sort = false;
} else {
// field name may be preceded by a space, or any number
// of characters followed by a dot (tablename.fieldname)
@@ -762,7 +764,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// for the sort expression (avoids problems with queries
// like "SELECT id, count(id)..." and clicking to sort
// 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.
// If it contains some, it's probably a function column
@@ -904,7 +906,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
<?php
}
return TRUE;
return true;
} // end of the 'PMA_displayTableHeaders()' function
@@ -1066,7 +1068,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
. '&amp;primary_key=' . $uva_condition
. '&amp;sql_query=' . urlencode($url_sql_query)
. '&amp;goto=' . urlencode($lnk_goto);
if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) {
if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
$edit_str = $GLOBALS['strEdit'];
} else {
$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']
.' " title="' . $GLOBALS['strExecuteBookmarked'] . '">';
if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) {
if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
$bookmark_go .= $GLOBALS['strExecuteBookmarked'];
} else {
$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;goto=' . urlencode($lnk_goto);
$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';
if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) {
if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
$del_str = $GLOBALS['strDelete'];
} else {
$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);
$del_query = urlencode('KILL ' . $row[0]);
$js_conf = 'KILL ' . $row[0];
if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) {
if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
$del_str = $GLOBALS['strKill'];
} else {
$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']
&& ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
$doWriteModifyAt = 'left';
require('./libraries/display_tbl_links.lib.php');
require './libraries/display_tbl_links.lib.php';
} // end if (1.3)
} // 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 ($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'] . '\');"'
. ' 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 . '\');" ';
} else {
$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)) {
$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)) {
$transform_function = 'PMA_transformation_' . $transformfunction_name;
@@ -1282,7 +1284,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// 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
// TEXT fields type, however TEXT fields must be displayed
// 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']
&& ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
$doWriteModifyAt = 'right';
require('./libraries/display_tbl_links.lib.php');
require './libraries/display_tbl_links.lib.php';
} // end if (3)
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
@@ -1434,12 +1436,12 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
}
$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'] . '\');"'
. ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
}
$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'] . '\');';
}
@@ -1455,7 +1457,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
if (isset($edit_url)) {
$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
. ' </td>' . "\n";
} else {
@@ -1464,7 +1466,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
if (isset($del_url)) {
$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";
} else {
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;
}
return TRUE;
return true;
} // end of the 'PMA_displayTableBody()' function
@@ -1623,7 +1625,7 @@ function PMA_displayVerticalTable()
echo '</tr>' . "\n";
}
return TRUE;
return true;
} // end of the 'PMA_displayVerticalTable' function
@@ -1717,7 +1719,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
? $total - 1
: $pos_next - 1;
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 PMA_sanitize(sprintf($GLOBALS['strViewMaxExactCount'], PMA_formatNumber($GLOBALS['cfg']['MaxExactCount'], 0), '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]')) . "\n";
echo '</div>' . "\n";
@@ -1763,7 +1765,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
if ($cfgRelation['displaywork']) {
if (! isset($table) || ! strlen($table)) {
$exist_rel = FALSE;
$exist_rel = false;
} else {
$exist_rel = PMA_getForeigners($db, $table, '', 'both');
if ($exist_rel) {

View File

@@ -3,6 +3,8 @@
// vim: expandtab sw=4 ts=4 sts=4:
require_once './libraries/Table.class.php';
/**
* Gets foreign keys in preparation for a drop-down selector
* 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
// 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']) {
// foreign_display can be FALSE if no display field defined:

View File

@@ -2,6 +2,8 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
require_once './libraries/Table.class.php';
/**
* 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
if ($mode == 'native' && isset($table) && strlen($table)) {
$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);
return TRUE;
}

View File

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

View File

@@ -6,6 +6,7 @@
* Gets some core libraries
*/
require_once './libraries/common.lib.php';
require_once './libraries/Table.class.php';
require_once './libraries/tbl_indexes.lib.php';
require_once './libraries/check_user_privileges.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) {
$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);
}
/**
@@ -453,7 +454,7 @@ else {
) {
// "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 "

View File

@@ -2,6 +2,8 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
require_once './libraries/Table.class.php';
/**
* Gets some core libraries
*/
@@ -58,7 +60,7 @@ if (isset($do_save_data)) {
$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
// To allow replication, we first select the db to use and then run queries