
'
. __("Favorite List is full!")
. '
';
} else {
// Otherwise add to favorite list.
$fav_instance->add($db, $favorite_table);
}
}
}
$favorite_tables[$user] = $fav_instance->getTables();
$ajax_response = PMA_Response::getInstance();
$ajax_response->addJSON(
'changes',
$changes
);
if ($changes) {
$ajax_response->addJSON(
'user',
$user
);
$ajax_response->addJSON(
'favorite_tables',
json_encode($favorite_tables)
);
$ajax_response->addJSON(
'list',
$fav_instance->getHtmlList()
);
$ajax_response->addJSON(
'anchor',
PMA\Template::get('structure/favorite_anchor')->render(
array(
'db' => $db,
'current_table' => array('TABLE_NAME' => $favorite_table),
'titles' => $titles
)
)
);
} else {
$ajax_response->addJSON(
'message',
$msg
);
}
}
/**
* Synchronize favorite tables
*
* @param PMA_RecentFavoriteTable $fav_instance Instance of this class
* @param string $user The user hash
* @param array $favorite_tables Existing favorites
*
* @return void
*/
function PMA_synchronizeFavoriteTables($fav_instance, $user, $favorite_tables)
{
$fav_instance_tables = $fav_instance->getTables();
if (empty($fav_instance_tables)
&& isset($favorite_tables[$user])
) {
foreach ($favorite_tables[$user] as $key => $value) {
$fav_instance->add($value['db'], $value['table']);
}
}
$favorite_tables[$user] = $fav_instance->getTables();
$ajax_response = PMA_Response::getInstance();
$ajax_response->addJSON(
'favorite_tables',
json_encode($favorite_tables)
);
$ajax_response->addJSON(
'list',
$fav_instance->getHtmlList()
);
$server_id = $GLOBALS['server'];
// Set flag when localStorage and pmadb(if present) are in sync.
$_SESSION['tmpval']['favorites_synced'][$server_id] = true;
}
/**
* Returns the real row count for a table
*
* @param string $db Database name
* @param string $table Table name
*
* @return number
*/
function PMA_getRealRowCountTable($db, $table)
{
// SQL query to get row count for a table.
$sql_query = 'SELECT COUNT(*) AS ' . PMA_Util::backquote('row_count')
. ' FROM ' . PMA_Util::backquote($db) . '.'
. PMA_Util::backquote($table);
$result = $GLOBALS['dbi']->fetchSingleRow($sql_query);
$row_count = $result['row_count'];
return $row_count;
}
/**
* Returns the real row count for all tables of a DB
*
* @param string $db Database name
* @param array $tables Array containing table names.
*
* @return array
*/
function PMA_getRealRowCountDb($db, $tables)
{
// Array to store the results.
$row_count_all = array();
// Iterate over each table and fetch real row count.
foreach ($tables as $table) {
$row_count = PMA_getRealRowCountTable($db, $table['TABLE_NAME']);
array_push(
$row_count_all,
array('table' => $table['TABLE_NAME'], 'row_count' => $row_count)
);
}
return $row_count_all;
}
/**
* Handles request for real row count on database level view page.
*
* @return boolean true
*/
function PMA_handleRealRowCountRequest()
{
$ajax_response = PMA_Response::getInstance();
// If there is a request to update all table's row count.
if (isset($_REQUEST['real_row_count_all'])) {
$real_row_count_all = PMA_getRealRowCountDb(
$GLOBALS['db'],
$GLOBALS['tables']
);
$ajax_response->addJSON(
'real_row_count_all',
json_encode($real_row_count_all)
);
return true;
}
// Get the real row count for the table.
$real_row_count = PMA_getRealRowCountTable(
$GLOBALS['db'],
$_REQUEST['table']
);
// Format the number.
$real_row_count = PMA_Util::formatNumber($real_row_count, 0);
$ajax_response->addJSON('real_row_count', $real_row_count);
return true;
}
/**
* Possibly show the table creation dialog
*
* @param string $db Current database name
* @param bool $db_is_system_schema Whether this db is a system schema
* @param PMA_Response $response PMA_Response instance
*
* @return void
*/
function PMA_possiblyShowCreateTableDialog($db, $db_is_system_schema, $response)
{
if (empty($db_is_system_schema)) {
ob_start();
include 'libraries/display_create_table.lib.php';
$content = ob_get_contents();
ob_end_clean();
$response->addHTML($content);
} // end if (Create Table dialog)
}
/**
* Returns the HTML for secondary levels tabs of the table structure page
*
* @param string $tbl_storage_engine storage engine of the table
*
* @return string HTML for secondary levels tabs
*/
function PMA_getStructureSecondaryTabs($tbl_storage_engine)
{
$html_output = '';
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['relwork']
|| PMA_Util::isForeignKeySupported(strtoupper($tbl_storage_engine))
) {
$url_params = array();
$url_params['db'] = $GLOBALS['db'];
$url_params['table'] = $GLOBALS['table'];
$html_output .= '';
$html_output .= '