本文整理汇总了PHP中PMA_DBI_get_tables_full函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_DBI_get_tables_full函数的具体用法?PHP PMA_DBI_get_tables_full怎么用?PHP PMA_DBI_get_tables_full使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_DBI_get_tables_full函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_tabs
/**
* retrieves table info and stores it in $GLOBALS['PMD']
*
* @uses $GLOBALS['script_display_field']
* @uses $GLOBALS['PMD'] to fill it
* @uses $GLOBALS['db']
* @uses PMA_DBI_get_tables_full()
* @uses PMA_DBI_select_db()
* @uses PMA_getDisplayField()
* @uses urlencode()
* @uses htmlspecialchars()
* @uses strtoupper()
* @uses urlencode()
*/
function get_tabs()
{
$GLOBALS['PMD']['TABLE_NAME'] = array();
// that foreach no error
$GLOBALS['PMD']['OWNER'] = array();
$GLOBALS['PMD']['TABLE_NAME_SMALL'] = array();
$tables = PMA_DBI_get_tables_full($GLOBALS['db']);
// seems to be needed later
PMA_DBI_select_db($GLOBALS['db']);
$i = 0;
foreach ($tables as $one_table) {
$GLOBALS['PMD']['TABLE_NAME'][$i] = $GLOBALS['db'] . "." . $one_table['TABLE_NAME'];
$GLOBALS['PMD']['OWNER'][$i] = $GLOBALS['db'];
$GLOBALS['PMD']['TABLE_NAME_SMALL'][$i] = $one_table['TABLE_NAME'];
$GLOBALS['PMD_URL']['TABLE_NAME'][$i] = urlencode($GLOBALS['db'] . "." . $one_table['TABLE_NAME']);
$GLOBALS['PMD_URL']['OWNER'][$i] = urlencode($GLOBALS['db']);
$GLOBALS['PMD_URL']['TABLE_NAME_SMALL'][$i] = urlencode($one_table['TABLE_NAME']);
$GLOBALS['PMD_OUT']['TABLE_NAME'][$i] = htmlspecialchars($GLOBALS['db'] . "." . $one_table['TABLE_NAME'], ENT_QUOTES);
$GLOBALS['PMD_OUT']['OWNER'][$i] = htmlspecialchars($GLOBALS['db'], ENT_QUOTES);
$GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$i] = htmlspecialchars($one_table['TABLE_NAME'], ENT_QUOTES);
$GLOBALS['PMD']['TABLE_TYPE'][$i] = strtoupper($one_table['ENGINE']);
$DF = PMA_getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']);
if ($DF != '') {
$GLOBALS['script_display_field'] .= " display_field['" . $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i] . "'] = '" . urlencode($DF) . "';\n";
}
$i++;
}
$GLOBALS['script_display_field'] .= '// ]]>' . "\n" . '</script>' . "\n";
// return $GLOBALS['PMD']; // many bases // not use ??????
}
示例2: get_tables_info
/**
* retrieves table info and stores it in $GLOBALS['PMD']
*
* @return array with table info
*/
function get_tables_info()
{
$retval = array();
$GLOBALS['PMD']['TABLE_NAME'] = array();
// that foreach no error
$GLOBALS['PMD']['OWNER'] = array();
$GLOBALS['PMD']['TABLE_NAME_SMALL'] = array();
$tables = PMA_DBI_get_tables_full($GLOBALS['db']);
// seems to be needed later
PMA_DBI_select_db($GLOBALS['db']);
$i = 0;
foreach ($tables as $one_table) {
$GLOBALS['PMD']['TABLE_NAME'][$i] = $GLOBALS['db'] . "." . $one_table['TABLE_NAME'];
$GLOBALS['PMD']['OWNER'][$i] = $GLOBALS['db'];
$GLOBALS['PMD']['TABLE_NAME_SMALL'][$i] = $one_table['TABLE_NAME'];
$GLOBALS['PMD_URL']['TABLE_NAME'][$i] = urlencode($GLOBALS['db'] . "." . $one_table['TABLE_NAME']);
$GLOBALS['PMD_URL']['OWNER'][$i] = urlencode($GLOBALS['db']);
$GLOBALS['PMD_URL']['TABLE_NAME_SMALL'][$i] = urlencode($one_table['TABLE_NAME']);
$GLOBALS['PMD_OUT']['TABLE_NAME'][$i] = htmlspecialchars($GLOBALS['db'] . "." . $one_table['TABLE_NAME'], ENT_QUOTES);
$GLOBALS['PMD_OUT']['OWNER'][$i] = htmlspecialchars($GLOBALS['db'], ENT_QUOTES);
$GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$i] = htmlspecialchars($one_table['TABLE_NAME'], ENT_QUOTES);
$GLOBALS['PMD']['TABLE_TYPE'][$i] = strtoupper($one_table['ENGINE']);
$DF = PMA_getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']);
if ($DF != '') {
$retval[$GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i]] = urlencode($DF);
}
$i++;
}
return $retval;
}
示例3: PMA_getTableList
/**
* returns array with tables of given db with extended information and grouped
*
* @param string $db name of db
* @param string $tables name of tables
* @param integer $limit_offset list offset
* @param int|bool $limit_count max tables to return
*
* @return array (recursive) grouped table list
*/
function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count = false)
{
$sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
if (null === $tables) {
$tables = PMA_DBI_get_tables_full($db, false, false, null, $limit_offset, $limit_count);
if ($GLOBALS['cfg']['NaturalOrder']) {
uksort($tables, 'strnatcasecmp');
}
}
if (count($tables) < 1) {
return $tables;
}
$default = array('Name' => '', 'Rows' => 0, 'Comment' => '', 'disp_name' => '');
$table_groups = array();
// for blobstreaming - list of blobstreaming tables
// load PMA configuration
$PMA_Config = $GLOBALS['PMA_Config'];
foreach ($tables as $table_name => $table) {
// if BS tables exist
if (PMA_BS_IsHiddenTable($table_name)) {
continue;
}
// check for correct row count
if (null === $table['Rows']) {
// Do not check exact row count here,
// 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 or the
// information_schema database
// since PMA_Table::countRecords() returns a limited row count
// in this case.
// set this because PMA_Table::countRecords() can use it
$tbl_is_view = $table['TABLE_TYPE'] == 'VIEW';
if ($tbl_is_view || PMA_is_system_schema($db)) {
$table['Rows'] = PMA_Table::countRecords($db, $table['Name'], false, true);
}
}
// in $group we save the reference to the place in $table_groups
// where to store the table info
if ($GLOBALS['cfg']['LeftFrameDBTree'] && $sep && strstr($table_name, $sep)) {
$parts = explode($sep, $table_name);
$group =& $table_groups;
$i = 0;
$group_name_full = '';
$parts_cnt = count($parts) - 1;
while ($i < $parts_cnt && $i < $GLOBALS['cfg']['LeftFrameTableLevel']) {
$group_name = $parts[$i] . $sep;
$group_name_full .= $group_name;
if (!isset($group[$group_name])) {
$group[$group_name] = array();
$group[$group_name]['is' . $sep . 'group'] = true;
$group[$group_name]['tab' . $sep . 'count'] = 1;
$group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
} elseif (!isset($group[$group_name]['is' . $sep . 'group'])) {
$table = $group[$group_name];
$group[$group_name] = array();
$group[$group_name][$group_name] = $table;
unset($table);
$group[$group_name]['is' . $sep . 'group'] = true;
$group[$group_name]['tab' . $sep . 'count'] = 1;
$group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
} else {
$group[$group_name]['tab' . $sep . 'count']++;
}
$group =& $group[$group_name];
$i++;
}
} else {
if (!isset($table_groups[$table_name])) {
$table_groups[$table_name] = array();
}
$group =& $table_groups;
}
if ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested' && $table['Comment'] && $table['Comment'] != 'VIEW') {
// switch tooltip and name
$table['disp_name'] = $table['Comment'];
$table['Comment'] = $table['Name'];
} else {
$table['disp_name'] = $table['Name'];
}
$group[$table_name] = array_merge($default, $table);
}
return $table_groups;
}
示例4: htmlspecialchars
$myfieldname = 'Tables_in_' . htmlspecialchars($db);
$table = $row[$myfieldname];
if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
$comments = PMA_getComments($db, $table);
}
if ($count != 0) {
echo '<div style="page-break-before: always;">' . "\n";
} else {
echo '<div>' . "\n";
}
echo '<h2>' . $table . '</h2>' . "\n";
/**
* Gets table informations
*/
// The 'show table' statement works correct since 3.23.03
$showtable = PMA_DBI_get_tables_full($db, $table);
$num_rows = isset($showtable[$table]['TABLE_ROWS']) ? $showtable[$table]['TABLE_ROWS'] : 0;
$show_comment = isset($showtable[$table]['TABLE_COMMENT']) ? $showtable[$table]['TABLE_COMMENT'] : '';
unset($showtable);
/**
* Gets table keys and retains them
*/
PMA_DBI_select_db($db);
$result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
$primary = '';
$indexes = array();
$lastIndex = '';
$indexes_info = array();
$indexes_data = array();
$pk_array = array();
// will be use to emphasis prim. keys in the table
示例5: PMA_DBI_getVirtualTables
/**
* Get VIEWs in a particular database
*
* @param string $db Database name to look in
*
* @return array $views Set of VIEWs inside the database
*/
function PMA_DBI_getVirtualTables($db)
{
$tables_full = PMA_DBI_get_tables_full($db);
$views = array();
foreach ($tables_full as $table => $tmp) {
if (PMA_Table::isView($db, $table)) {
$views[] = $table;
}
}
return $views;
}
示例6: extract
<?php
/* $Id: pmd_relation_new.php 9828 2007-01-05 17:30:36Z lem9 $ */
// vim: expandtab sw=4 ts=4 sts=4:
include_once 'pmd_common.php';
$die_save_pos = 0;
include_once 'pmd_save_pos.php';
require_once './libraries/relation.lib.php';
extract($_POST);
$tables = PMA_DBI_get_tables_full($db, $T1);
$type_T1 = strtoupper($tables[$T1]['ENGINE']);
$tables = PMA_DBI_get_tables_full($db, $T2);
//print_r($tables);
//die();
$type_T2 = strtoupper($tables[$T2]['ENGINE']);
// I n n o D B
if ($type_T1 == 'INNODB' and $type_T2 == 'INNODB') {
// relation exists?
$existrel_innodb = PMA_getForeigners($db, $T2, '', 'innodb');
if (isset($existrel_innodb[$F2]) && isset($existrel_innodb[$F2]['constraint'])) {
PMD_return(0, 'strErrorRelationExists');
}
// note: in InnoDB, the index does not requires to be on a PRIMARY
// or UNIQUE key
// improve: check all other requirements for InnoDB relations
$result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($T1) . ';');
$index_array1 = array();
// will be use to emphasis prim. keys in the table view
while ($row = PMA_DBI_fetch_assoc($result)) {
$index_array1[$row['Column_name']] = 1;
}
示例7: countRecords
/**
* 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 force an exact count
*
* @return mixed the number of records if "retain" param is true,
* otherwise true
*
* @access public
*/
public static function countRecords($db, $table, $force_exact = false, $is_view = null)
{
if (isset(PMA_Table::$cache[$db][$table]['ExactRows'])) {
$row_count = PMA_Table::$cache[$db][$table]['ExactRows'];
} else {
$row_count = false;
if (null === $is_view) {
$is_view = PMA_Table::isView($db, $table);
}
if (!$force_exact) {
if (!isset(PMA_Table::$cache[$db][$table]['Rows']) && !$is_view) {
$tmp_tables = PMA_DBI_get_tables_full($db, $table);
if (isset($tmp_tables[$table])) {
PMA_Table::$cache[$db][$table] = $tmp_tables[$table];
}
}
if (isset(PMA_Table::$cache[$db][$table]['Rows'])) {
$row_count = PMA_Table::$cache[$db][$table]['Rows'];
} else {
$row_count = false;
}
}
// for a VIEW, $row_count is always false at this point
if (false === $row_count || $row_count < $GLOBALS['cfg']['MaxExactCount']) {
if (!$is_view) {
//print_r($GLOBALS['cfg']['Server']);
if ($db && $db != 'undefined' && $db != strtoupper($GLOBALS['cfg']['Server']['user'])) {
$row_count = PMA_DBI_fetch_value('SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.' . PMA_backquote(strtoupper($table)));
} else {
$row_count = PMA_DBI_fetch_value('SELECT COUNT(*) FROM ' . PMA_backquote(strtoupper($table)));
}
} else {
// For complex views, even trying to get a partial record
// count could bring down a server, so we offer an
// alternative: setting MaxExactCountViews to 0 will bypass
// completely the record counting for views
if ($GLOBALS['cfg']['MaxExactCountViews'] == 0) {
$row_count = 0;
} else {
// Counting all rows of a VIEW could be too long, so use
// a LIMIT clause.
// Use try_query because it can fail (when a VIEW is
// based on a table that no longer exists)
$result = PMA_DBI_try_query('SELECT 1 FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT ' . $GLOBALS['cfg']['MaxExactCountViews'], null, PMA_DBI_QUERY_STORE);
//print_r('xxxxyyy');
if (!PMA_DBI_getError()) {
$row_count = PMA_DBI_num_rows($result);
PMA_DBI_free_result($result);
}
}
}
PMA_Table::$cache[$db][$table]['ExactRows'] = $row_count;
}
}
return $row_count;
}
示例8: PMA_DBI_get_tables
// - get the total number of tables
// (needed for proper working of the MaxTableList feature)
$tables = PMA_DBI_get_tables($db);
$total_num_tables = count($tables);
if (isset($sub_part) && $sub_part == '_export') {
// (don't fetch only a subset if we are coming from db_export.php,
// because I think it's too risky to display only a subset of the
// table names when exporting a db)
/**
*
* @todo Page selector for table names?
*/
$tables = PMA_DBI_get_tables_full($db, false, false, null, 0, false, $sort, $sort_order);
} else {
// fetch the details for a possible limited subset
$tables = PMA_DBI_get_tables_full($db, false, false, null, $pos, true, $sort, $sort_order);
}
}
if ($cfg['ShowTooltip']) {
foreach ($tables as $each_table) {
PMA_fillTooltip($tooltip_truename, $tooltip_aliasname, $each_table);
}
}
}
/**
* @global int count of tables in db
*/
$num_tables = count($tables);
// (needed for proper working of the MaxTableList feature)
if (!isset($total_num_tables)) {
$total_num_tables = $num_tables;
示例9: processRelations
/**
* process internal and foreign key relations
*
* @param string $db The database name
* @param integer $pageNumber document number/Id
* @param array $cfgRelation relation settings
*
* @return void
* @access private
*/
public function processRelations($db, $pageNumber, $cfgRelation)
{
/*
* A u t o m a t i c l a y o u t
*
* There are 2 kinds of relations in PMA
* 1) Internal Relations 2) Foreign Key Relations
*/
if (isset($this->autoLayoutInternal) || isset($this->autoLayoutForeign)) {
$all_tables = array();
}
if (isset($this->autoLayoutForeign)) {
/*
* get the tables list
* who support FOREIGN KEY, it's not
* important that we group together InnoDB tables
* and PBXT tables, as this logic is just to put
* the tables on the layout, not to determine relations
*/
$tables = PMA_DBI_get_tables_full($db);
$foreignkey_tables = array();
foreach ($tables as $table_name => $table_properties) {
if (PMA_foreignkey_supported($table_properties['ENGINE'])) {
$foreignkey_tables[] = $table_name;
}
}
$all_tables = $foreignkey_tables;
/*
* could be improved by finding the tables which have the
* most references keys and placing them at the beginning
* of the array (so that they are all center of schema)
*/
unset($tables, $foreignkey_tables);
}
if (isset($this->autoLayoutInternal)) {
/*
* get the tables list who support Internal Relations;
* This type of relations will be created when
* you setup the PMA tables correctly
*/
$master_tables = 'SELECT COUNT(master_table), master_table' . ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\'' . ' GROUP BY master_table' . ' ORDER BY COUNT(master_table) DESC';
$master_tables_rs = PMA_query_as_controluser($master_tables, false, PMA_DBI_QUERY_STORE);
if ($master_tables_rs && PMA_DBI_num_rows($master_tables_rs) > 0) {
/* first put all the master tables at beginning
* of the list, so they are near the center of
* the schema
*/
while (list(, $master_table) = PMA_DBI_fetch_row($master_tables_rs)) {
$all_tables[] = $master_table;
}
/* Now for each master, add its foreigns into an array
* of foreign tables, if not already there
* (a foreign might be foreign for more than
* one table, and might be a master itself)
*/
$foreign_tables = array();
foreach ($all_tables as $master_table) {
$foreigners = PMA_getForeigners($db, $master_table);
foreach ($foreigners as $foreigner) {
if (!in_array($foreigner['foreign_table'], $foreign_tables)) {
$foreign_tables[] = $foreigner['foreign_table'];
}
}
}
/*
* Now merge the master and foreign arrays/tables
*/
foreach ($foreign_tables as $foreign_table) {
if (!in_array($foreign_table, $all_tables)) {
$all_tables[] = $foreign_table;
}
}
}
}
if (isset($this->autoLayoutInternal) || isset($this->autoLayoutForeign)) {
$this->addRelationCoordinates($all_tables, $pageNumber, $db, $cfgRelation);
}
$this->chosenPage = $pageNumber;
}
示例10: PMA_DBI_get_tables
// all tables in db
// - get the total number of tables
$tables = PMA_DBI_get_tables($db);
$total_num_tables = count($tables);
if (isset($sub_part) && $sub_part == '_export') {
// (don't fetch only a subset if we are coming from db_export.php,
// because I think it's too risky to display only a subset of the
// table names when exporting a db)
/**
*
* @todo Page selector for table names?
*/
$tables = PMA_DBI_get_tables_full($db, false, false, null, 0, false);
} else {
// fetch the details for a possible limited subset
$tables = PMA_DBI_get_tables_full($db, false, false, null, $pos, true);
}
}
if ($cfg['ShowTooltip']) {
foreach ($tables as $each_table) {
PMA_fillTooltip($tooltip_truename, $tooltip_aliasname, $each_table);
}
}
}
/**
* @global int count of tables in db
*/
$num_tables = count($tables);
if (!isset($total_num_tables)) {
$total_num_tables = $num_tables;
}
示例11: PMA_getTableList
/**
* returns array with tables of given db with extended infomation and grouped
*
* @uses $GLOBALS['cfg']['LeftFrameTableSeparator']
* @uses $GLOBALS['cfg']['LeftFrameTableLevel']
* @uses $GLOBALS['cfg']['ShowTooltipAliasTB']
* @uses $GLOBALS['cfg']['NaturalOrder']
* @uses PMA_DBI_fetch_result()
* @uses PMA_backquote()
* @uses count()
* @uses array_merge
* @uses uksort()
* @uses strstr()
* @uses explode()
* @param string $db name of db
* return array (rekursive) grouped table list
*/
function PMA_getTableList($db, $tables = null)
{
$sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
if (null === $tables) {
$tables = PMA_DBI_get_tables_full($db);
if ($GLOBALS['cfg']['NaturalOrder']) {
uksort($tables, 'strnatcasecmp');
}
}
if (count($tables) < 1) {
return $tables;
}
$default = array('Name' => '', 'Rows' => 0, 'Comment' => '', 'disp_name' => '');
$table_groups = array();
foreach ($tables as $table_name => $table) {
// check for correct row count
if (null === $table['Rows']) {
// Do not check exact row count here,
// 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_Table::countRecords() returns a limited row count
// in this case.
// 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_Table::countRecords($db, $table['Name'], $return = true);
}
}
// in $group we save the reference to the place in $table_groups
// where to store the table info
if ($GLOBALS['cfg']['LeftFrameDBTree'] && $sep && strstr($table_name, $sep)) {
$parts = explode($sep, $table_name);
$group =& $table_groups;
$i = 0;
$group_name_full = '';
while ($i < count($parts) - 1 && $i < $GLOBALS['cfg']['LeftFrameTableLevel']) {
$group_name = $parts[$i] . $sep;
$group_name_full .= $group_name;
if (!isset($group[$group_name])) {
$group[$group_name] = array();
$group[$group_name]['is' . $sep . 'group'] = true;
$group[$group_name]['tab' . $sep . 'count'] = 1;
$group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
} elseif (!isset($group[$group_name]['is' . $sep . 'group'])) {
$table = $group[$group_name];
$group[$group_name] = array();
$group[$group_name][$group_name] = $table;
unset($table);
$group[$group_name]['is' . $sep . 'group'] = true;
$group[$group_name]['tab' . $sep . 'count'] = 1;
$group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
} else {
$group[$group_name]['tab' . $sep . 'count']++;
}
$group =& $group[$group_name];
$i++;
}
} else {
if (!isset($table_groups[$table_name])) {
$table_groups[$table_name] = array();
}
$group =& $table_groups;
}
if ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested') {
// switch tooltip and name
$table['Comment'] = $table['Name'];
$table['disp_name'] = $table['Comment'];
} else {
$table['disp_name'] = $table['Name'];
}
$group[$table_name] = array_merge($default, $table);
}
return $table_groups;
}
示例12: PMA_getTableList
/**
* returns array with tables of given db with extended information and grouped
*
* @uses $cfg['LeftFrameTableSeparator']
* @uses $cfg['LeftFrameTableLevel']
* @uses $cfg['ShowTooltipAliasTB']
* @uses $cfg['NaturalOrder']
* @uses PMA_backquote()
* @uses count()
* @uses array_merge
* @uses uksort()
* @uses strstr()
* @uses explode()
* @param string $db name of db
* @param string $tables name of tables
* @param integer $limit_offset list offset
* @param integer $limit_count max tables to return
* return array (recursive) grouped table list
*/
function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count = false)
{
$sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
if (null === $tables) {
$tables = PMA_DBI_get_tables_full($db, false, false, null, $limit_offset, $limit_count);
if ($GLOBALS['cfg']['NaturalOrder']) {
uksort($tables, 'strnatcasecmp');
}
}
if (count($tables) < 1) {
return $tables;
}
$default = array('Name' => '', 'Rows' => 0, 'Comment' => '', 'disp_name' => '');
$table_groups = array();
// for blobstreaming - list of blobstreaming tables - rajk
// load PMA configuration
$PMA_Config = $_SESSION['PMA_Config'];
// if PMA configuration exists
if (!empty($PMA_Config)) {
$session_bs_tables = $_SESSION['PMA_Config']->get('BLOBSTREAMING_TABLES');
}
foreach ($tables as $table_name => $table) {
// if BS tables exist
if (isset($session_bs_tables)) {
// compare table name to tables in list of blobstreaming tables
foreach ($session_bs_tables as $table_key => $table_val) {
// if table is in list, skip outer foreach loop
if ($table_name == $table_key) {
continue 2;
}
}
}
// check for correct row count
if (null === $table['Rows']) {
// Do not check exact row count here,
// 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 or the
// information_schema database
// since PMA_Table::countRecords() returns a limited row count
// in this case.
// set this because PMA_Table::countRecords() can use it
$tbl_is_view = PMA_Table::isView($db, $table['Name']);
if ($tbl_is_view || 'information_schema' == $db) {
$table['Rows'] = PMA_Table::countRecords($db, $table['Name'], $return = true);
}
}
// in $group we save the reference to the place in $table_groups
// where to store the table info
if ($GLOBALS['cfg']['LeftFrameDBTree'] && $sep && strstr($table_name, $sep)) {
$parts = explode($sep, $table_name);
$group =& $table_groups;
$i = 0;
$group_name_full = '';
while ($i < count($parts) - 1 && $i < $GLOBALS['cfg']['LeftFrameTableLevel']) {
$group_name = $parts[$i] . $sep;
$group_name_full .= $group_name;
if (!isset($group[$group_name])) {
$group[$group_name] = array();
$group[$group_name]['is' . $sep . 'group'] = true;
$group[$group_name]['tab' . $sep . 'count'] = 1;
$group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
} elseif (!isset($group[$group_name]['is' . $sep . 'group'])) {
$table = $group[$group_name];
$group[$group_name] = array();
$group[$group_name][$group_name] = $table;
unset($table);
$group[$group_name]['is' . $sep . 'group'] = true;
$group[$group_name]['tab' . $sep . 'count'] = 1;
$group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
} else {
$group[$group_name]['tab' . $sep . 'count']++;
}
$group =& $group[$group_name];
$i++;
}
} else {
if (!isset($table_groups[$table_name])) {
$table_groups[$table_name] = array();
}
$group =& $table_groups;
//.........这里部分代码省略.........
示例13: getTableList
/**
* returns array with tables of given db with extended information and grouped
*
* @param string $db name of db
* @param string $tables name of tables
* @param integer $limit_offset list offset
* @param int|bool $limit_count max tables to return
*
* @return array (recursive) grouped table list
*/
public static function getTableList(
$db, $tables = null, $limit_offset = 0, $limit_count = false
) {
$sep = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
if ($tables === null) {
$tables = PMA_DBI_get_tables_full(
$db, false, false, null, $limit_offset, $limit_count
);
if ($GLOBALS['cfg']['NaturalOrder']) {
uksort($tables, 'strnatcasecmp');
}
}
if (count($tables) < 1) {
return $tables;
}
$default = array(
'Name' => '',
'Rows' => 0,
'Comment' => '',
'disp_name' => '',
);
$table_groups = array();
foreach ($tables as $table_name => $table) {
// check for correct row count
if ($table['Rows'] === null) {
// Do not check exact row count here,
// 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 or the
// information_schema database
// since PMA_Table::countRecords() returns a limited row count
// in this case.
// set this because PMA_Table::countRecords() can use it
$tbl_is_view = $table['TABLE_TYPE'] == 'VIEW';
if ($tbl_is_view || PMA_is_system_schema($db)) {
$table['Rows'] = PMA_Table::countRecords(
$db,
$table['Name'],
false,
true
);
}
}
// in $group we save the reference to the place in $table_groups
// where to store the table info
if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']
&& $sep && strstr($table_name, $sep)
) {
$parts = explode($sep, $table_name);
$group =& $table_groups;
$i = 0;
$group_name_full = '';
$parts_cnt = count($parts) - 1;
while (($i < $parts_cnt)
&& ($i < $GLOBALS['cfg']['NavigationTreeTableLevel'])
) {
$group_name = $parts[$i] . $sep;
$group_name_full .= $group_name;
if (! isset($group[$group_name])) {
$group[$group_name] = array();
$group[$group_name]['is' . $sep . 'group'] = true;
$group[$group_name]['tab' . $sep . 'count'] = 1;
$group[$group_name]['tab' . $sep . 'group']
= $group_name_full;
} elseif (! isset($group[$group_name]['is' . $sep . 'group'])) {
$table = $group[$group_name];
$group[$group_name] = array();
$group[$group_name][$group_name] = $table;
unset($table);
$group[$group_name]['is' . $sep . 'group'] = true;
$group[$group_name]['tab' . $sep . 'count'] = 1;
$group[$group_name]['tab' . $sep . 'group']
= $group_name_full;
} else {
$group[$group_name]['tab' . $sep . 'count']++;
}
//.........这里部分代码省略.........
示例14: sGetStatusInfo
/**
* Returns full table status info, or specific if $info provided
*
* this info is collected from information_schema
*
* @todo PMA_DBI_get_tables_full needs to be merged somehow into this class or at least better documented
* @param string $db
* @param string $table
* @param string $info
* @param boolean $force_read
* @return mixed
*/
public static function sGetStatusInfo($db, $table, $info = null, $force_read = false)
{
if (!isset(PMA_Table::$cache[$db][$table]) || $force_read) {
PMA_DBI_get_tables_full($db, $table);
}
if (!isset(PMA_Table::$cache[$db][$table])) {
// happens when we enter the table creation dialog
// or when we really did not get any status info, for example
// when $table == 'TABLE_NAMES' after the user tried SHOW TABLES
return '';
}
if (null === $info) {
return PMA_Table::$cache[$db][$table];
}
if (!isset(PMA_Table::$cache[$db][$table][$info])) {
trigger_error('unknown table status: ' . $info, E_USER_WARNING);
return false;
}
return PMA_Table::$cache[$db][$table][$info];
}
示例15: loadStructure
/**
* loads structure data
*/
function loadStructure()
{
$table_info = PMA_DBI_get_tables_full($this->getDbName(), $this->getName());
if (false === $table_info) {
return false;
}
$this->settings = $table_info;
if ($this->get('TABLE_ROWS') === null) {
$this->set('TABLE_ROWS', PMA_Table::countRecords($this->getDbName(), $this->getName(), true, true));
}
$create_options = explode(' ', $this->get('TABLE_ROWS'));
// export create options by its name as variables into gloabel namespace
// f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
foreach ($create_options as $each_create_option) {
$each_create_option = explode('=', $each_create_option);
if (isset($each_create_option[1])) {
$this->set(${$each_create_option}[0], $each_create_option[1]);
}
}
}