本文整理汇总了PHP中PMA_DBI_select_db函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_DBI_select_db函数的具体用法?PHP PMA_DBI_select_db怎么用?PHP PMA_DBI_select_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_DBI_select_db函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_DBI_get_dblist
function PMA_DBI_get_dblist($link = NULL)
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
$res = PMA_DBI_try_query('SHOW DATABASES;', $link);
$dbs_array = array();
while ($row = PMA_DBI_fetch_row($res)) {
// Before MySQL 4.0.2, SHOW DATABASES could send the
// whole list, so check if we really have access:
//if (PMA_MYSQL_CLIENT_API < 40002) {
// Better check the server version, in case the client API
// is more recent than the server version
if (PMA_MYSQL_INT_VERSION < 40002) {
$dblink = @PMA_DBI_select_db($row[0], $link);
if (!$dblink) {
continue;
}
}
$dbs_array[] = $row[0];
}
PMA_DBI_free_result($res);
unset($res);
return $dbs_array;
}
示例2: get_script_contr
/**
* returns JavaScript code for intializing vars
*
* @return string JavaScript code
*/
function get_script_contr()
{
PMA_DBI_select_db($GLOBALS['db']);
$con["C_NAME"] = array();
$i = 0;
$alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($GLOBALS['db']), null, PMA_DBI_QUERY_STORE);
while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
$row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'internal');
//echo "<br> internal ".$GLOBALS['db']." - ".$val[0]." - ";
//print_r($row);
if ($row !== false) {
foreach ($row as $field => $value) {
$con['C_NAME'][$i] = '';
$con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]);
$con['DCN'][$i] = urlencode($field);
$con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']);
$con['SCN'][$i] = urlencode($value['foreign_field']);
$i++;
}
}
$row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'foreign');
//echo "<br> INNO ";
//print_r($row);
if ($row !== false) {
foreach ($row as $field => $value) {
$con['C_NAME'][$i] = '';
$con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]);
$con['DCN'][$i] = urlencode($field);
$con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']);
$con['SCN'][$i] = urlencode($value['foreign_field']);
$i++;
}
}
}
$ti = 0;
$script_contr = '<script type="text/javascript">' . "\n" . '// <![CDATA[' . "\n" . 'var contr = new Array();' . "\n";
for ($i = 0, $cnt = count($con["C_NAME"]); $i < $cnt; $i++) {
$js_var = ' contr[' . $ti . ']';
$script_contr .= $js_var . " = new Array();\n";
$js_var .= "['" . $con['C_NAME'][$i] . "']";
$script_contr .= $js_var . " = new Array();\n";
if (in_array($con['DTN'][$i], $GLOBALS['PMD_URL']["TABLE_NAME"]) && in_array($con['STN'][$i], $GLOBALS['PMD_URL']["TABLE_NAME"])) {
$js_var .= "['" . $con['DTN'][$i] . "']";
$script_contr .= $js_var . " = new Array();\n";
$m_col = array();
//}
$js_var .= "['" . $con['DCN'][$i] . "']";
$script_contr .= $js_var . " = new Array();\n";
//}
$script_contr .= $js_var . "[0] = '" . $con['STN'][$i] . "';\n";
//
$script_contr .= $js_var . "[1] = '" . $con['SCN'][$i] . "';\n";
//
}
$ti++;
}
$script_contr .= '// ]]>' . "\n" . '</script>' . "\n";
return $script_contr;
}
示例3: _checkAccess
/**
* removes all databases not accessible by current user from list
*
* @access protected
* @uses PMA_List_Database::$items
* @uses PMA_List_Database::$_db_link_user
* @uses PMA_List_Database::$_need_to_reindex to set it if reuqired
* @uses PMA_DBI_select_db()
*/
function _checkAccess()
{
foreach ($this->items as $key => $db) {
if (!@PMA_DBI_select_db($db, $this->_db_link_user)) {
unset($this->items[$key]);
}
}
// re-index values
$this->_need_to_reindex = true;
}
示例4: get_script_contr
/**
* returns JavaScript code for intializing vars
*
* @return string JavaScript code
*/
function get_script_contr()
{
PMA_DBI_select_db($GLOBALS['db']);
$con["C_NAME"] = array();
$i = 0;
$alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_Util::backquote($GLOBALS['db']), null, PMA_DBI_QUERY_STORE);
while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
$row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'internal');
//echo "<br> internal ".$GLOBALS['db']." - ".$val[0]." - ";
//print_r($row);
if ($row !== false) {
foreach ($row as $field => $value) {
$con['C_NAME'][$i] = '';
$con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]);
$con['DCN'][$i] = urlencode($field);
$con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']);
$con['SCN'][$i] = urlencode($value['foreign_field']);
$i++;
}
}
$row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'foreign');
//echo "<br> INNO ";
//print_r($row);
if ($row !== false) {
foreach ($row as $field => $value) {
$con['C_NAME'][$i] = '';
$con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]);
$con['DCN'][$i] = urlencode($field);
$con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']);
$con['SCN'][$i] = urlencode($value['foreign_field']);
$i++;
}
}
}
$ti = 0;
$retval = array();
for ($i = 0, $cnt = count($con["C_NAME"]); $i < $cnt; $i++) {
$c_name_i = $con['C_NAME'][$i];
$dtn_i = $con['DTN'][$i];
$retval[$ti] = array();
$retval[$ti][$c_name_i] = array();
if (in_array($dtn_i, $GLOBALS['PMD_URL']["TABLE_NAME"]) && in_array($con['STN'][$i], $GLOBALS['PMD_URL']["TABLE_NAME"])) {
$retval[$ti][$c_name_i][$dtn_i] = array();
$retval[$ti][$c_name_i][$dtn_i][$con['DCN'][$i]] = array(0 => $con['STN'][$i], 1 => $con['SCN'][$i]);
}
$ti++;
}
return $retval;
}
示例5: PMA_query_as_cu
/**
* Executes a query as controluser if possible, otherwise as normal user
*
* @param string the query to execute
* @param boolean whether to display SQL error messages or not
*
* @return integer the result id
*
* @global string the URL of the page to show in case of error
* @global string the name of db to come back to
* @global resource the resource id of DB connect as controluser
* @global array configuration infos about the relations stuff
*
* @access public
*
* @author Mike Beck <mikebeck@users.sourceforge.net>
*/
function PMA_query_as_cu($sql, $show_error = TRUE, $options = 0)
{
global $err_url_0, $db, $dbh, $cfgRelation;
PMA_DBI_select_db($cfgRelation['db'], $dbh);
if ($show_error) {
$result = PMA_DBI_query($sql, $dbh, $options);
} else {
$result = @PMA_DBI_try_query($sql, $dbh, $options);
}
// end if... else...
PMA_DBI_select_db($db, $dbh);
if ($result) {
return $result;
} else {
return FALSE;
}
}
示例6: PMA_showMySQLDocu
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH') . "\n";
?>
</td>
</tr>
<?php
// Referential integrity check
// The Referential integrity check was intended for the non-InnoDB
// tables for which the relations are defined in pmadb
// so I assume that if the current table is InnoDB, I don't display
// this choice (InnoDB maintains integrity by itself)
if ($cfgRelation['relwork'] && $tbl_type != "INNODB") {
// we need this PMA_DBI_select_db if the user has access to more than one db
// and $db is not the last of the list, because PMA_availableDatabases()
// has made a PMA_DBI_select_db() on the last one
PMA_DBI_select_db($db);
$foreign = PMA_getForeigners($db, $table);
if ($foreign) {
?>
<!-- Referential integrity check -->
<tr>
<td bgcolor="<?php
echo $cfg['BgcolorOne'];
?>
" colspan="2">
<?php
echo $strReferentialIntegrity;
?>
<br />
<?php
echo "\n";
示例7: PMA_availableDatabases
/**
* Get the list and number of available databases.
*
* @param string the url to go back to in case of error
*
* @return boolean always true
*
* @global array the list of available databases
* @global integer the number of available databases
* @global array current configuration
*/
function PMA_availableDatabases($error_url = '')
{
global $dblist;
global $num_dbs;
global $cfg;
$num_dbs = count($dblist);
// 1. A list of allowed databases has already been defined by the
// authentification process -> gets the available databases list
if ($num_dbs) {
$true_dblist = array();
for ($i = 0; $i < $num_dbs; $i++) {
$dblink = @PMA_DBI_select_db($dblist[$i]);
if ($dblink) {
$true_dblist[] = $dblist[$i];
}
// end if
}
// end for
$dblist = array();
$dblist = $true_dblist;
unset($true_dblist);
$num_dbs = count($dblist);
} else {
if (!isset($cfg['Server']['only_db']) || $cfg['Server']['only_db'] == '') {
$dblist = PMA_DBI_get_dblist();
// needed? or PMA_mysqlDie('', 'SHOW DATABASES;', FALSE, $error_url);
$num_dbs = count($dblist);
}
}
// end else
return TRUE;
}
示例8: PMA_generate_common_url
* Note: this can be called also from the db panel to get the privileges of
* a db, in which case we want to keep displaying the tabs of
* the Database panel
*/
if (empty($viewing_mode)) {
$db = $table = '';
}
/**
* Set parameters for links
*/
$url_query = PMA_generate_common_url($db);
/**
* Defines the urls to return to in case of error in a sql statement
*/
$err_url = 'main.php' . $url_query;
/**
* Displays the headers
*/
require_once './libraries/header.inc.php';
/**
* @global boolean Checks for superuser privileges
*/
$is_superuser = PMA_isSuperuser();
// now, select the mysql db
if ($is_superuser) {
PMA_DBI_select_db('mysql', $userlink);
}
/**
* @global array binary log files
*/
$binary_logs = PMA_DBI_fetch_result('SHOW MASTER LOGS', 'Log_name', null, null, PMA_DBI_QUERY_STORE);
示例9: PMA_displayTableHeaders
/**
* Displays the headers of the results table
*
* @param array which elements to display
* @param array the list of fields properties
* @param integer the total number of fields returned by the sql query
* @param array the analyzed query
*
* @return boolean always true
*
* @global string $db the database name
* @global string $table the table name
* @global string $goto the url to go back in case of errors
* @global boolean $dontlimitchars whether to limit the number of displayed
* characters of text type fields or not
* @global string $sql_query the sql query
* @global integer $num_rows the total number of rows returned by the
* sql query
* @global integer $pos the current position in results
* @global integer $session_max_rows the maximum number of rows per page
* @global array $vertical_display informations used with vertical display
* mode
* @global string $disp_direction the display mode
* (horizontal/vertical/horizontalflipped)
* @global integer $repeat_cellsthe number of row to display between two
* table headers
*
* @access private
*
* @see PMA_displayTable()
*/
function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '')
{
global $db, $table, $goto, $dontlimitchars;
global $sql_query, $num_rows, $pos, $session_max_rows;
global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
if ($analyzed_sql == '') {
$analyzed_sql = array();
}
// can the result be sorted?
if ($is_display['sort_lnk'] == '1') {
// Just as fallback
$unsorted_sql_query = $sql_query;
if (isset($analyzed_sql[0]['unsorted_query'])) {
$unsorted_sql_query = $analyzed_sql[0]['unsorted_query'];
}
// we need $sort_expression and $sort_expression_nodir
// even if there are many table references
$sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']));
// Get rid of ASC|DESC (TODO: analyzer)
preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches);
$sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
// sorting by indexes, only if it makes sense (only one table ref)
if (isset($analyzed_sql) && isset($analyzed_sql[0]) && isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' && isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) {
// grab indexes data:
PMA_DBI_select_db($db);
if (!defined('PMA_IDX_INCLUDED')) {
$ret_keys = PMA_get_indexes($table);
}
$prev_index = '';
foreach ($ret_keys as $row) {
if ($row['Key_name'] != $prev_index) {
$indexes[] = $row['Key_name'];
$prev_index = $row['Key_name'];
}
$indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
$indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
if (isset($row['Cardinality'])) {
$indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
}
// I don't know what does the following column mean....
// $indexes_info[$row['Key_name']]['Packed'] = $row['Packed'];
$indexes_info[$row['Key_name']]['Comment'] = isset($row['Comment']) ? $row['Comment'] : '';
$indexes_info[$row['Key_name']]['Index_type'] = isset($row['Index_type']) ? $row['Index_type'] : '';
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
if (isset($row['Sub_part'])) {
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
}
}
// end while
// do we have any index?
if (isset($indexes_data)) {
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
$span = $fields_cnt;
if ($is_display['edit_lnk'] != 'nn') {
$span++;
}
if ($is_display['del_lnk'] != 'nn') {
$span++;
}
if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') {
$span++;
}
} else {
$span = $num_rows + floor($num_rows / $repeat_cells) + 1;
}
echo '<form action="sql.php" method="post">' . "\n";
echo PMA_generate_common_hidden_inputs($db, $table, 5);
echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
//.........这里部分代码省略.........
示例10: PMA_replication_synchronize_db
/**
* This function provides synchronization of structure and data between two mysql servers.
* TODO: improve code sharing between the function and synchronization
*
* @param String $db - name of database, which should be synchronized
* @param mixed $src_link - link of source server, note: if the server is current PMA server, use null
* @param mixed $trg_link - link of target server, note: if the server is current PMA server, use null
* @param boolean $data - if true, then data will be copied as well
*/
function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
{
$src_db = $trg_db = $db;
$src_connection = PMA_DBI_select_db($src_db, $src_link);
$trg_connection = PMA_DBI_select_db($trg_db, $trg_link);
$src_tables = PMA_DBI_get_tables($src_db, $src_link);
$source_tables_num = sizeof($src_tables);
$trg_tables = PMA_DBI_get_tables($trg_db, $trg_link);
$target_tables_num = sizeof($trg_tables);
/**
* initializing arrays to save table names
*/
$unmatched_num_src = 0;
$source_tables_uncommon = array();
$unmatched_num_trg = 0;
$target_tables_uncommon = array();
$matching_tables = array();
$matching_tables_num = 0;
/**
* Criterion for matching tables is just their names.
* Finding the uncommon tables for the source database
* BY comparing the matching tables with all the tables in the source database
*/
PMA_getMatchingTables($trg_tables, $src_tables, $matching_tables, $source_tables_uncommon);
/**
* Finding the uncommon tables for the target database
* BY comparing the matching tables with all the tables in the target database
*/
PMA_getNonMatchingTargetTables($trg_tables, $matching_tables, $target_tables_uncommon);
/**
*
* Comparing Data In the Matching Tables
* It is assumed that the matching tables are structurally
* and typely exactly the same
*/
$fields_num = array();
$matching_tables_fields = array();
$matching_tables_keys = array();
$insert_array = array(array(array()));
$update_array = array(array(array()));
$delete_array = array();
$row_count = array();
$uncommon_tables_fields = array();
$matching_tables_num = sizeof($matching_tables);
for ($i = 0; $i < sizeof($matching_tables); $i++) {
PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $matching_tables_fields, $update_array, $insert_array, $delete_array, $fields_num, $i, $matching_tables_keys);
}
for ($j = 0; $j < sizeof($source_tables_uncommon); $j++) {
PMA_dataDiffInUncommonTables($source_tables_uncommon, $src_db, $src_link, $j, $row_count);
}
/**
* INTEGRATION OF STRUCTURE DIFFERENCE CODE
*
*/
$source_columns = array();
$target_columns = array();
$alter_str_array = array(array());
$add_column_array = array(array());
$uncommon_columns = array();
$target_tables_keys = array();
$source_indexes = array();
$target_indexes = array();
$add_indexes_array = array();
$remove_indexes_array = array();
$criteria = array('Field', 'Type', 'Null', 'Collation', 'Key', 'Default', 'Comment');
for ($counter = 0; $counter < $matching_tables_num; $counter++) {
PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $source_columns, $target_columns, $alter_str_array, $add_column_array, $uncommon_columns, $criteria, $target_tables_keys, $counter);
PMA_indexesDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $source_indexes, $target_indexes, $add_indexes_array, $alter_indexes_array, $remove_indexes_array, $counter);
}
$matching_table_data_diff = array();
$matching_table_structure_diff = array();
$uncommon_table_structure_diff = array();
$uncommon_table_data_diff = array();
$uncommon_tables = $source_tables_uncommon;
/**
* Generating Create Table query for all the non-matching tables present in Source but not in Target and populating tables.
*/
for ($q = 0; $q < sizeof($source_tables_uncommon); $q++) {
if (isset($uncommon_tables[$q])) {
PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, $source_tables_uncommon, $q, $uncommon_tables_fields, false);
}
if (isset($row_count[$q]) && $data) {
PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link, $source_tables_uncommon, $q, $uncommon_tables_fields, false);
}
}
}
示例11: PMA_exportStructure
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $dummy)
{
global $cfgRelation;
if (!PMA_exportOutputHandler('<h2>' . $GLOBALS['strTableStructure'] . ' ' . $table . '</h2>')) {
return FALSE;
}
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
$result = PMA_DBI_query($local_query);
$fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck)
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = TRUE;
} else {
$have_rel = FALSE;
}
} else {
$have_rel = FALSE;
}
// end if
/**
* Displays the table structure
*/
if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return FALSE;
}
$columns_cnt = 4;
if ($do_relation && $have_rel) {
$columns_cnt++;
}
if ($do_comments && $cfgRelation['commwork']) {
$columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
}
$schema_insert = '<tr class="print-category">';
$schema_insert .= '<th class="print">' . htmlspecialchars($GLOBALS['strField']) . '</th>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars($GLOBALS['strType']) . '</b></td>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars($GLOBALS['strNull']) . '</b></td>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars($GLOBALS['strDefault']) . '</b></td>';
if ($do_relation && $have_rel) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars($GLOBALS['strLinksTo']) . '</b></td>';
}
if ($do_comments) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars($GLOBALS['strComments']) . '</b></td>';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars('MIME') . '</b></td>';
$mime_map = PMA_getMIME($db, $table, true);
}
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
while ($row = PMA_DBI_fetch_assoc($result)) {
$schema_insert = '<tr class="print-category">';
$type = $row['Type'];
// reformat mysql query output - staybyte - 9. June 2001
// loic1: set or enum types: slashes single quotes inside options
if (preg_match('/^(set|enum)\\((.+)\\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = ' ';
}
$binary = preg_match('/BINARY/i', $row['Type']);
$unsigned = preg_match('/UNSIGNED/i', $row['Type']);
$zerofill = preg_match('/ZEROFILL/i', $row['Type']);
}
$strAttribute = ' ';
//.........这里部分代码省略.........
示例12: PMA_BS_CreateReferenceLink
/**
* creates a HTTP link to a given blob reference for a given database
*
* @access public
* @param string - BLOB reference
* @param string - database name
* @uses PMA_Config::get()
* @uses PMA_DBI_select_db()
* @uses PMA_backquote()
* @uses PMA_sqlAddslashes()
* @uses PMA_DBI_query()
* @uses PMA_DBI_fetch_assoc()
* @return string - HTTP link or Error
*/
function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
{
// load PMA configuration
$PMA_Config = $_SESSION['PMA_Config'];
// return if unable to load PMA configuration
if (empty($PMA_Config)) {
return '';
}
// generate bs reference link
$bs_ref_link = 'http://' . $PMA_Config->get('BLOBSTREAMING_SERVER') . '/' . $bs_reference;
// select specified database
PMA_DBI_select_db($db_name);
$pbms_repo_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_repository");
$pbms_ref_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_reference");
$pbms_cust_content_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_custom_content_type");
// run query on determining specified BS reference
$query = "SELECT {$pbms_repo_bq}.Content_type, {$pbms_cust_content_bq}.Content_type AS Custom_type";
$query .= " FROM {$pbms_repo_bq} LEFT JOIN {$pbms_ref_bq} ON";
$query .= "{$pbms_repo_bq}.Repository_id={$pbms_ref_bq}.Repository_id";
$query .= " AND {$pbms_repo_bq}.Blob_size={$pbms_ref_bq}.Blob_size";
$query .= " AND {$pbms_repo_bq}.Repo_blob_offset={$pbms_ref_bq}.Repo_blob_offset";
$query .= " LEFT JOIN {$pbms_cust_content_bq} ON {$pbms_cust_content_bq}.Blob_url={$pbms_ref_bq}.Blob_url";
$query .= " WHERE {$pbms_ref_bq}.Blob_url='" . PMA_sqlAddslashes($bs_reference) . "'";
$result = PMA_DBI_query($query);
// if record exists
if ($data = @PMA_DBI_fetch_assoc($result)) {
// determine content-type for BS repository file (original or custom)
$is_custom_type = false;
if (isset($data['Custom_type'])) {
$content_type = $data['Custom_type'];
$is_custom_type = true;
} else {
$content_type = $data['Content_type'];
}
if (!$content_type) {
$content_type = NULL;
}
$output = "<a href=\"#\" onclick=\"requestMIMETypeChange('" . urlencode($db_name) . "', '" . urlencode($GLOBALS['table']) . "', '" . urlencode($bs_reference) . "', '" . urlencode($content_type) . "')\">{$content_type}</a>";
// specify custom HTML for various content types
switch ($content_type) {
// no content specified
case NULL:
$output = "NULL";
break;
// image content
// image content
case 'image/jpeg':
case 'image/png':
$output .= ' (<a href="' . $bs_ref_link . '" target="new">' . $GLOBALS['strViewImage'] . '</a>)';
break;
// audio content
// audio content
case 'audio/mpeg':
$output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . urlencode($content_type) . '\',' . ($is_custom_type ? 1 : 0) . ', 640, 120)">' . $GLOBALS['strPlayAudio'] . '</a>)';
break;
// video content
// video content
case 'application/x-flash-video':
case 'video/mpeg':
$output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . urlencode($content_type) . '\',' . ($is_custom_type ? 1 : 0) . ', 640, 480)">' . $GLOBALS['strViewVideo'] . '</a>)';
break;
// unsupported content. specify download
// unsupported content. specify download
default:
$output .= ' (<a href="' . $bs_ref_link . '" target="new">' . $GLOBALS['strDownloadFile'] . '</a>)';
}
// return HTML
return $output;
}
// end if ($data = @PMA_DBI_fetch_assoc($result))
// return on error
return 'Error';
}
示例13: _processExportSchema
/**
* get all the export options and verify
* call and include the appropriate Schema Class depending on $export_type
*
* @return void
* @access private
*/
private function _processExportSchema()
{
/**
* Settings for relation stuff
*/
include_once './libraries/transformations.lib.php';
include_once './libraries/Index.class.php';
/**
* default is PDF, otherwise validate it's only letters a-z
*/
global $db, $export_type;
if (!isset($export_type) || !preg_match('/^[a-zA-Z]+$/', $export_type)) {
$export_type = 'pdf';
}
PMA_DBI_select_db($db);
include "./libraries/schema/" . ucfirst($export_type) . "_Relation_Schema.class.php";
$obj_schema = eval("new PMA_" . ucfirst($export_type) . "_Relation_Schema();");
}
示例14: PMA_exportStructure
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column comments
* as comments in the structure; this is deprecated
* but the parameter is left here because export.php
* calls PMA_exportStructure() also for other export
* types which use this parameter
* @param bool $do_mime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $export_type 'server', 'database', 'table'
*
* @return bool Whether it succeeded
*
* @access public
*/
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
{
global $cfgRelation;
/* We do not export triggers */
if ($export_mode == 'triggers') {
return true;
}
/**
* Get the unique keys in the table
*/
$unique_keys = array();
$keys = PMA_DBI_get_table_indexes($db, $table);
foreach ($keys as $key) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
// Check if we can use Relations
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = true;
} else {
$have_rel = false;
}
} else {
$have_rel = false;
}
// end if
/**
* Displays the table structure
*/
$buffer = $crlf . '%' . $crlf . '% ' . __('Structure') . ': ' . $table . $crlf . '%' . $crlf . ' \\begin{longtable}{';
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
$columns_cnt = 4;
$alignment = '|l|c|c|c|';
if ($do_relation && $have_rel) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_comments) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
$alignment .= 'l|';
}
$buffer = $alignment . '} ' . $crlf;
$header = ' \\hline ';
$header .= '\\multicolumn{1}{|c|}{\\textbf{' . __('Column') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Type') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Null') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Default') . '}}';
if ($do_relation && $have_rel) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Links to') . '}}';
}
if ($do_comments) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Comments') . '}}';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{MIME}}';
$mime_map = PMA_getMIME($db, $table, true);
}
// Table caption for first page and label
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{' . PMA_expandUserString($GLOBALS['latex_structure_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db)) . '} \\label{' . PMA_expandUserString($GLOBALS['latex_structure_label'], null, array('table' => $table, 'database' => $db)) . '} \\\\' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline' . $crlf . '\\endfirsthead' . $crlf;
// Table caption on next pages
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{' . PMA_expandUserString($GLOBALS['latex_structure_continued_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db)) . '} \\\\ ' . $crlf;
//.........这里部分代码省略.........
示例15: PMA_getRelationsParam
/**
* Defines the relation parameters for the current user
* just a copy of the functions used for relations ;-)
* but added some stuff to check what will work
*
* @param boolean whether to check validity of settings or not
*
* @return array the relation parameters for the current user
*
* @global array the list of settings for servers
* @global integer the id of the current server
* @global string the URL of the page to show in case of error
* @global string the name of the current db
* @global string the name of the current table
* @global array configuration infos about the relations stuff
*
* @access public
*
* @author Mike Beck <mikebeck@users.sourceforge.net>
*/
function PMA_getRelationsParam($verbose = FALSE)
{
global $cfg, $server, $err_url_0, $db, $table, $controllink;
global $cfgRelation;
$cfgRelation = array();
$cfgRelation['relwork'] = FALSE;
$cfgRelation['displaywork'] = FALSE;
$cfgRelation['bookmarkwork'] = FALSE;
$cfgRelation['pdfwork'] = FALSE;
$cfgRelation['commwork'] = FALSE;
$cfgRelation['mimework'] = FALSE;
$cfgRelation['historywork'] = FALSE;
$cfgRelation['allworks'] = FALSE;
// No server selected -> no bookmark table
// we return the array with the FALSEs in it,
// to avoid some 'Unitialized string offset' errors later
if ($server == 0 || empty($cfg['Server']) || empty($cfg['Server']['pmadb'])) {
if ($verbose == TRUE) {
echo 'PMA Database ... ' . '<font color="red"><b>' . $GLOBALS['strNotOK'] . '</b></font>' . '[ <a href="Documentation.html#pmadb">' . $GLOBALS['strDocu'] . '</a> ]<br />' . "\n" . $GLOBALS['strGeneralRelationFeat'] . ' <font color="green">' . $GLOBALS['strDisabled'] . '</font>' . "\n";
}
return $cfgRelation;
}
$cfgRelation['user'] = $cfg['Server']['user'];
$cfgRelation['db'] = $cfg['Server']['pmadb'];
// Now I just check if all tables that i need are present so I can for
// example enable relations but not pdf...
// I was thinking of checking if they have all required columns but I
// fear it might be too slow
PMA_DBI_select_db($cfgRelation['db'], $controllink);
$tab_query = 'SHOW TABLES FROM ' . PMA_backquote($cfgRelation['db']);
$tab_rs = PMA_query_as_cu($tab_query, FALSE, PMA_DBI_QUERY_STORE);
if ($tab_rs) {
while ($curr_table = @PMA_DBI_fetch_row($tab_rs)) {
if ($curr_table[0] == $cfg['Server']['bookmarktable']) {
$cfgRelation['bookmark'] = $curr_table[0];
} elseif ($curr_table[0] == $cfg['Server']['relation']) {
$cfgRelation['relation'] = $curr_table[0];
} elseif ($curr_table[0] == $cfg['Server']['table_info']) {
$cfgRelation['table_info'] = $curr_table[0];
} elseif ($curr_table[0] == $cfg['Server']['table_coords']) {
$cfgRelation['table_coords'] = $curr_table[0];
} elseif ($curr_table[0] == $cfg['Server']['column_info']) {
$cfgRelation['column_info'] = $curr_table[0];
} elseif ($curr_table[0] == $cfg['Server']['pdf_pages']) {
$cfgRelation['pdf_pages'] = $curr_table[0];
} elseif ($curr_table[0] == $cfg['Server']['history']) {
$cfgRelation['history'] = $curr_table[0];
}
}
// end while
}
if (isset($cfgRelation['relation'])) {
$cfgRelation['relwork'] = TRUE;
if (isset($cfgRelation['table_info'])) {
$cfgRelation['displaywork'] = TRUE;
}
}
if (isset($cfgRelation['table_coords']) && isset($cfgRelation['pdf_pages'])) {
$cfgRelation['pdfwork'] = TRUE;
}
if (isset($cfgRelation['column_info'])) {
$cfgRelation['commwork'] = TRUE;
if ($cfg['Server']['verbose_check']) {
$mime_query = 'SHOW FIELDS FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']);
$mime_rs = PMA_query_as_cu($mime_query, FALSE);
$mime_field_mimetype = FALSE;
$mime_field_transformation = FALSE;
$mime_field_transformation_options = FALSE;
while ($curr_mime_field = @PMA_DBI_fetch_row($mime_rs)) {
if ($curr_mime_field[0] == 'mimetype') {
$mime_field_mimetype = TRUE;
} elseif ($curr_mime_field[0] == 'transformation') {
$mime_field_transformation = TRUE;
} elseif ($curr_mime_field[0] == 'transformation_options') {
$mime_field_transformation_options = TRUE;
}
}
PMA_DBI_free_result($mime_rs);
if ($mime_field_mimetype == TRUE && $mime_field_transformation == TRUE && $mime_field_transformation_options == TRUE) {
$cfgRelation['mimework'] = TRUE;
//.........这里部分代码省略.........