本文整理汇总了PHP中PMA_sqlAddSlashes函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_sqlAddSlashes函数的具体用法?PHP PMA_sqlAddSlashes怎么用?PHP PMA_sqlAddSlashes使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_sqlAddSlashes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddSlashes
/**
* sqlAddslashes test
*/
public function testAddSlashes()
{
$string = "\\'test''\\''\\'\r\t\n";
$this->assertEquals("\\\\\\\\\\'test\\'\\'\\\\\\\\\\'\\'\\\\\\\\\\'\\r\\t\\n", PMA_sqlAddSlashes($string, true, true, true));
$this->assertEquals("\\\\\\\\''test''''\\\\\\\\''''\\\\\\\\''\\r\\t\\n", PMA_sqlAddSlashes($string, true, true, false));
$this->assertEquals("\\\\\\\\\\'test\\'\\'\\\\\\\\\\'\\'\\\\\\\\\\'\r\t\n", PMA_sqlAddSlashes($string, true, false, true));
$this->assertEquals("\\\\\\\\''test''''\\\\\\\\''''\\\\\\\\''\r\t\n", PMA_sqlAddSlashes($string, true, false, false));
$this->assertEquals("\\\\\\'test\\'\\'\\\\\\'\\'\\\\\\'\\r\\t\\n", PMA_sqlAddSlashes($string, false, true, true));
$this->assertEquals("\\\\''test''''\\\\''''\\\\''\\r\\t\\n", PMA_sqlAddSlashes($string, false, true, false));
$this->assertEquals("\\\\\\'test\\'\\'\\\\\\'\\'\\\\\\'\r\t\n", PMA_sqlAddSlashes($string, false, false, true));
$this->assertEquals("\\\\''test''''\\\\''''\\\\''\r\t\n", PMA_sqlAddSlashes($string, false, false, false));
}
示例2: PMA_EVN_getQueryFromRequest
/**
* Composes the query necessary to create an event from an HTTP request.
*
* @return string The CREATE EVENT query.
*/
function PMA_EVN_getQueryFromRequest()
{
global $_REQUEST, $errors, $event_status, $event_type, $event_interval;
$query = 'CREATE ';
if (!empty($_REQUEST['item_definer'])) {
if (strpos($_REQUEST['item_definer'], '@') !== false) {
$arr = explode('@', $_REQUEST['item_definer']);
$query .= 'DEFINER=' . PMA_backquote($arr[0]);
$query .= '@' . PMA_backquote($arr[1]) . ' ';
} else {
$errors[] = __('The definer must be in the "username@hostname" format');
}
}
$query .= 'EVENT ';
if (!empty($_REQUEST['item_name'])) {
$query .= PMA_backquote($_REQUEST['item_name']) . ' ';
} else {
$errors[] = __('You must provide an event name');
}
$query .= 'ON SCHEDULE ';
if (!empty($_REQUEST['item_type']) && in_array($_REQUEST['item_type'], $event_type)) {
if ($_REQUEST['item_type'] == 'RECURRING') {
if (!empty($_REQUEST['item_interval_value']) && !empty($_REQUEST['item_interval_field']) && in_array($_REQUEST['item_interval_field'], $event_interval)) {
$query .= 'EVERY ' . intval($_REQUEST['item_interval_value']) . ' ';
$query .= $_REQUEST['item_interval_field'] . ' ';
} else {
$errors[] = __('You must provide a valid interval value for the event.');
}
if (!empty($_REQUEST['item_starts'])) {
$query .= "STARTS '" . PMA_sqlAddSlashes($_REQUEST['item_starts']) . "' ";
}
if (!empty($_REQUEST['item_ends'])) {
$query .= "ENDS '" . PMA_sqlAddSlashes($_REQUEST['item_ends']) . "' ";
}
} else {
if (!empty($_REQUEST['item_execute_at'])) {
$query .= "AT '" . PMA_sqlAddSlashes($_REQUEST['item_execute_at']) . "' ";
} else {
$errors[] = __('You must provide a valid execution time for the event.');
}
}
} else {
$errors[] = __('You must provide a valid type for the event.');
}
$query .= 'ON COMPLETION ';
if (empty($_REQUEST['item_preserve'])) {
$query .= 'NOT ';
}
$query .= 'PRESERVE ';
if (!empty($_REQUEST['item_status'])) {
foreach ($event_status['display'] as $key => $value) {
if ($value == $_REQUEST['item_status']) {
$query .= $event_status['query'][$key] . ' ';
break;
}
}
}
$query .= 'DO ';
if (!empty($_REQUEST['item_definition'])) {
$query .= $_REQUEST['item_definition'];
} else {
$errors[] = __('You must provide an event definition.');
}
return $query;
}
示例3: array
}
$tables_selected = array();
if (empty($_REQUEST['table_select']) || !is_array($_REQUEST['table_select'])) {
unset($_REQUEST['submit_search']);
} elseif (!isset($_REQUEST['selectall']) && !isset($_REQUEST['unselectall'])) {
$tables_selected = array_intersect($_REQUEST['table_select'], $tables_names_only);
}
if (isset($_REQUEST['selectall'])) {
$tables_selected = $tables_names_only;
} elseif (isset($_REQUEST['unselectall'])) {
$tables_selected = array();
}
if (empty($_REQUEST['field_str']) || !is_string($_REQUEST['field_str'])) {
unset($field_str);
} else {
$field_str = PMA_sqlAddSlashes($_REQUEST['field_str'], true);
}
/**
* Displays top links if we are not in an Ajax request
*/
$sub_part = '';
if ($GLOBALS['is_ajax_request'] != true) {
include 'libraries/db_info.inc.php';
echo '<div id="searchresults">';
}
/**
* 1. Main search form has been submitted
*/
if (isset($_REQUEST['submit_search'])) {
/**
* Builds the SQL search query
示例4: PMA_getDbCollation
/**
* returns collation of given db
*
* @uses PMA_DBI_fetch_value()
* @uses PMA_DBI_select_db()
* @uses PMA_sqlAddSlashes()
* @uses $GLOBALS['db']
* @param string $db name of db
* @return string collation of $db
*/
function PMA_getDbCollation($db)
{
if ($db == 'information_schema') {
// We don't have to check the collation of the virtual
// information_schema database: We know it!
return 'utf8_general_ci';
}
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
// this is slow with thousands of databases
return PMA_DBI_fetch_value('SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = \'' . PMA_sqlAddSlashes($db) . '\' LIMIT 1;');
} else {
PMA_DBI_select_db($db);
$return = PMA_DBI_fetch_value('SHOW VARIABLES LIKE \'collation_database\'', 0, 1);
if ($db !== $GLOBALS['db']) {
PMA_DBI_select_db($GLOBALS['db']);
}
return $return;
}
}
示例5: PMA_exportData
//.........这里部分代码省略.........
$current_row = 0;
$query_size = 0;
if (($GLOBALS['sql_insert_syntax'] == 'extended' || $GLOBALS['sql_insert_syntax'] == 'both') && (!isset($GLOBALS['sql_type']) || $GLOBALS['sql_type'] != 'UPDATE')) {
$separator = ',';
$schema_insert .= $crlf;
} else {
$separator = ';';
}
while ($row = PMA_DBI_fetch_row($result)) {
if ($current_row == 0) {
$head = PMA_possibleCRLF() . PMA_exportComment() . PMA_exportComment(__('Dumping data for table') . ' ' . $formatted_table_name) . PMA_exportComment() . $crlf;
if (!PMA_exportOutputHandler($head)) {
return false;
}
}
$current_row++;
for ($j = 0; $j < $fields_cnt; $j++) {
// NULL
if (!isset($row[$j]) || is_null($row[$j])) {
$values[] = 'NULL';
// a number
// timestamp is numeric on some MySQL 4.1, BLOBs are sometimes numeric
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && !$fields_meta[$j]->blob) {
$values[] = $row[$j];
// a true BLOB
// - mysqldump only generates hex data when the --hex-blob
// option is used, for fields having the binary attribute
// no hex is generated
// - a TEXT field returns type blob but a real blob
// returns also the 'binary' flag
} elseif (stristr($field_flags[$j], 'BINARY') && $fields_meta[$j]->blob && isset($GLOBALS['sql_hex_for_blob'])) {
// empty blobs need to be different, but '0' is also empty :-(
if (empty($row[$j]) && $row[$j] != '0') {
$values[] = '\'\'';
} else {
$values[] = '0x' . bin2hex($row[$j]);
}
// detection of 'bit' works only on mysqli extension
} elseif ($fields_meta[$j]->type == 'bit') {
$values[] = "b'" . PMA_sqlAddSlashes(PMA_printable_bit_value($row[$j], $fields_meta[$j]->length)) . "'";
// something else -> treat as a string
} else {
$values[] = '\'' . str_replace($search, $replace, PMA_sqlAddSlashes($row[$j])) . '\'';
}
// end if
}
// end for
// should we make update?
if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'UPDATE') {
$insert_line = $schema_insert;
for ($i = 0; $i < $fields_cnt; $i++) {
if (0 == $i) {
$insert_line .= ' ';
}
if ($i > 0) {
// avoid EOL blank
$insert_line .= ',';
}
$insert_line .= $field_set[$i] . ' = ' . $values[$i];
}
list($tmp_unique_condition, $tmp_clause_is_unique) = PMA_getUniqueCondition($result, $fields_cnt, $fields_meta, $row);
$insert_line .= ' WHERE ' . $tmp_unique_condition;
unset($tmp_unique_condition, $tmp_clause_is_unique);
} else {
// Extended inserts case
if ($GLOBALS['sql_insert_syntax'] == 'extended' || $GLOBALS['sql_insert_syntax'] == 'both') {
if ($current_row == 1) {
$insert_line = $schema_insert . '(' . implode(', ', $values) . ')';
} else {
$insert_line = '(' . implode(', ', $values) . ')';
if (isset($GLOBALS['sql_max_query_size']) && $GLOBALS['sql_max_query_size'] > 0 && $query_size + strlen($insert_line) > $GLOBALS['sql_max_query_size']) {
if (!PMA_exportOutputHandler(';' . $crlf)) {
return false;
}
$query_size = 0;
$current_row = 1;
$insert_line = $schema_insert . $insert_line;
}
}
$query_size += strlen($insert_line);
} else {
$insert_line = $schema_insert . '(' . implode(', ', $values) . ')';
}
}
unset($values);
if (!PMA_exportOutputHandler(($current_row == 1 ? '' : $separator . $crlf) . $insert_line)) {
return false;
}
}
// end while
if ($current_row > 0) {
if (!PMA_exportOutputHandler(';' . $crlf)) {
return false;
}
}
}
// end if ($result != false)
PMA_DBI_free_result($result);
return true;
}
示例6: PMA_sqlAddSlashes
}
$sql .= ' INFILE \'' . PMA_sqlAddSlashes($import_file) . '\'';
if (isset($ldi_replace)) {
$sql .= ' REPLACE';
} elseif (isset($ldi_ignore)) {
$sql .= ' IGNORE';
}
$sql .= ' INTO TABLE ' . PMA_backquote($table);
if (strlen($ldi_terminated) > 0) {
$sql .= ' FIELDS TERMINATED BY \'' . $ldi_terminated . '\'';
}
if (strlen($ldi_enclosed) > 0) {
$sql .= ' ENCLOSED BY \'' . PMA_sqlAddSlashes($ldi_enclosed) . '\'';
}
if (strlen($ldi_escaped) > 0) {
$sql .= ' ESCAPED BY \'' . PMA_sqlAddSlashes($ldi_escaped) . '\'';
}
if (strlen($ldi_new_line) > 0) {
if ($ldi_new_line == 'auto') {
$ldi_new_line = PMA_whichCrlf() == "\n" ? '\\n' : '\\r\\n';
}
$sql .= ' LINES TERMINATED BY \'' . $ldi_new_line . '\'';
}
if ($skip_queries > 0) {
$sql .= ' IGNORE ' . $skip_queries . ' LINES';
$skip_queries = 0;
}
if (strlen($ldi_columns) > 0) {
$sql .= ' (';
$tmp = preg_split('/,( ?)/', $ldi_columns);
$cnt_tmp = count($tmp);
示例7: PMA_backquote
echo '</div>';
}
// end if
}
// end if (!$is_information_schema)
// not sure about displaying the PDF dialog in case db is information_schema
if ($cfgRelation['pdfwork'] && $num_tables > 0) {
?>
<!-- Work on PDF Pages -->
<?php
// We only show this if we find something in the new pdf_pages table
$test_query = '
SELECT *
FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . '
WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
$test_rs = PMA_query_as_controluser($test_query, null, PMA_DBI_QUERY_STORE);
/*
* Export Relational Schema View
*/
echo '<div class="operations_full_width"><fieldset><a href="schema_edit.php?' . $url_query . '">';
if ($cfg['PropertiesIconic']) {
echo PMA_getImage('b_edit.png');
}
echo __('Edit or export relational schema') . '</a></fieldset></div>';
}
// end if
/**
* Displays the footer
*/
require 'libraries/footer.inc.php';
示例8: PMA_DBI_query
$db_info_result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
// Blending out tables in use
if ($db_info_result && PMA_DBI_num_rows($db_info_result) > 0) {
while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
// if in use memorize tablename
if (preg_match('@in_use=[1-9]+@i', $tmp[1])) {
$sot_cache[$tmp[0]] = true;
}
}
PMA_DBI_free_result($db_info_result);
if (isset($sot_cache)) {
$db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . $tbl_group_sql . ';', null, PMA_DBI_QUERY_STORE);
if ($db_info_result && PMA_DBI_num_rows($db_info_result) > 0) {
while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
if (!isset($sot_cache[$tmp[0]])) {
$sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddSlashes($tmp[0], true) . '\';');
$sts_tmp = PMA_DBI_fetch_assoc($sts_result);
PMA_DBI_free_result($sts_result);
unset($sts_result);
if (!isset($sts_tmp['Type']) && isset($sts_tmp['Engine'])) {
$sts_tmp['Type'] =& $sts_tmp['Engine'];
}
if (!empty($tbl_group) && $cfg['ShowTooltipAliasTB'] && !preg_match('@' . preg_quote($tbl_group, '@') . '@i', $sts_tmp['Comment'])) {
continue;
}
if ($cfg['ShowTooltip']) {
PMA_fillTooltip($tooltip_truename, $tooltip_aliasname, $sts_tmp);
}
$tables[$sts_tmp['Name']] = $sts_tmp;
} else {
// table in use
示例9: switch
$go_sql = false;
$executed_queries = 0;
$run_query = true;
$charset_conversion = false;
$reset_charset = false;
$bookmark_created = false;
// Bookmark Support: get a query back from bookmark if required
if (!empty($id_bookmark)) {
$id_bookmark = (int) $id_bookmark;
include_once './libraries/bookmark.lib.php';
switch ($action_bookmark) {
case 0:
// bookmarked query that have to be run
$import_text = PMA_Bookmark_get($db, $id_bookmark, 'id', isset($action_bookmark_all));
if (isset($bookmark_variable) && !empty($bookmark_variable)) {
$import_text = preg_replace('|/\\*(.*)\\[VARIABLE\\](.*)\\*/|imsU', '${1}' . PMA_sqlAddSlashes($bookmark_variable) . '${2}', $import_text);
}
// refresh left frame on changes in table or db structure
if (preg_match('/^(CREATE|ALTER|DROP)\\s+(VIEW|TABLE|DATABASE|SCHEMA)\\s+/i', $import_text)) {
$GLOBALS['reload'] = true;
}
break;
case 1:
// bookmarked query that have to be displayed
$import_text = PMA_Bookmark_get($db, $id_bookmark);
if ($GLOBALS['is_ajax_request'] == true) {
$extra_data['sql_query'] = $import_text;
$extra_data['action_bookmark'] = $action_bookmark;
$message = PMA_Message::success(__('Showing bookmark'));
PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
} else {
示例10: VALUES
(db_name, table_name, column_name, comment)
VALUES (
\'' . PMA_sqlAddSlashes($GLOBALS['db']) . '\',
\'' . PMA_sqlAddSlashes(trim($tab)) . '\',
\'' . PMA_sqlAddSlashes(trim($inf[0])) . '\',
\'' . PMA_sqlAddSlashes(trim($inf[1])) . '\')';
PMA_importRunQuery($qry, $qry . '-- ' . htmlspecialchars($tab) . '.' . htmlspecialchars($inf[0]), true);
}
// end inf[1] exists
if (!empty($inf[2]) && strlen(trim($inf[2])) > 0) {
$for = explode('->', $inf[2]);
$qry = '
INSERT INTO
' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '
(master_db, master_table, master_field, foreign_db, foreign_table, foreign_field)
VALUES (
\'' . PMA_sqlAddSlashes($GLOBALS['db']) . '\',
\'' . PMA_sqlAddSlashes(trim($tab)) . '\',
\'' . PMA_sqlAddSlashes(trim($inf[0])) . '\',
\'' . PMA_sqlAddSlashes($GLOBALS['db']) . '\',
\'' . PMA_sqlAddSlashes(trim($for[0])) . '\',
\'' . PMA_sqlAddSlashes(trim($for[1])) . '\')';
PMA_importRunQuery($qry, $qry . '-- ' . htmlspecialchars($tab) . '.' . htmlspecialchars($inf[0]) . '(' . htmlspecialchars($inf[2]) . ')', true);
}
// end inf[2] exists
}
// End lines loop
}
// End import
// Commit any possible data in buffers
PMA_importRunQuery();
示例11: PMA_getRelationsParam
*/
require_once './libraries/pmd_common.php';
$cfgRelation = PMA_getRelationsParam();
if (!$cfgRelation['designerwork']) {
PMD_err_sav();
}
foreach ($t_x as $key => $value) {
$KEY = empty($IS_AJAX) ? urldecode($key) : $key;
// table name decode (post PDF exp/imp)
list($DB, $TAB) = explode(".", $KEY);
PMA_query_as_controluser('DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['designer_coords']) . '
WHERE `db_name` = \'' . PMA_sqlAddSlashes($DB) . '\'
AND `table_name` = \'' . PMA_sqlAddSlashes($TAB) . '\'', true, PMA_DBI_QUERY_STORE);
PMA_query_as_controluser('INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['designer_coords']) . '
(db_name, table_name, x, y, v, h)
VALUES (' . '\'' . PMA_sqlAddSlashes($DB) . '\', ' . '\'' . PMA_sqlAddSlashes($TAB) . '\', ' . '\'' . PMA_sqlAddSlashes($t_x[$key]) . '\', ' . '\'' . PMA_sqlAddSlashes($t_y[$key]) . '\', ' . '\'' . PMA_sqlAddSlashes($t_v[$key]) . '\', ' . '\'' . PMA_sqlAddSlashes($t_h[$key]) . '\'' . ')', true, PMA_DBI_QUERY_STORE);
}
//----------------------------------------------------------------------------
function PMD_err_sav()
{
global $die_save_pos;
// if this file included
if (!empty($die_save_pos)) {
header("Content-Type: text/xml; charset=utf-8");
header("Cache-Control: no-cache");
die('<root act="save_pos" return="' . __('Error saving coordinates for Designer.') . '"></root>');
}
}
if (!empty($die_save_pos)) {
header("Content-Type: text/xml; charset=utf-8");
header("Cache-Control: no-cache");
示例12: PMA_backquote
// i n s e r t
if ($is_insert) {
// no need to add column into the valuelist
if (strlen($cur_value)) {
$query_values[] = $cur_value;
// first inserted row so prepare the list of fields
if (empty($value_sets)) {
$query_fields[] = PMA_backquote($me_fields_name[$key]);
}
}
// u p d a t e
} elseif (!empty($me_fields_null_prev[$key]) && !isset($me_fields_null[$key])) {
// field had the null checkbox before the update
// field no longer has the null checkbox
$query_values[] = PMA_backquote($me_fields_name[$key]) . ' = ' . $cur_value;
} elseif (empty($me_funcs[$key]) && isset($me_fields_prev[$key]) && "'" . PMA_sqlAddSlashes($me_fields_prev[$key]) . "'" == $val) {
// No change for this column and no MySQL function is used -> next column
continue;
} elseif (!empty($val)) {
// avoid setting a field to NULL when it's already NULL
// (field had the null checkbox before the update
// field still has the null checkbox)
if (empty($me_fields_null_prev[$key]) || empty($me_fields_null[$key])) {
$query_values[] = PMA_backquote($me_fields_name[$key]) . ' = ' . $cur_value;
}
}
}
// end foreach ($me_fields as $key => $val)
if (count($query_values) > 0) {
if ($is_insert) {
$value_sets[] = implode(', ', $query_values);
示例13: PMA_REL_create_page
/**
* Create a PDF page
*
* @param string $newpage name of the new PDF page
* @param array $cfgRelation
* @param string $db database name
*
* @return string $pdf_page_number
*/
function PMA_REL_create_page($newpage, $cfgRelation, $db)
{
if (!isset($newpage) || $newpage == '') {
$newpage = __('no description');
}
$ins_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . ' (db_name, page_descr)' . ' VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' . PMA_sqlAddSlashes($newpage) . '\')';
PMA_query_as_controluser($ins_query, false);
return PMA_DBI_insert_id(isset($GLOBALS['controllink']) ? $GLOBALS['controllink'] : '');
}
示例14: PMA_purgeHistory
/**
* purges SQL history
*
* deletes entries that exceeds $cfg['QueryHistoryMax'], oldest first, for the
* given user
*
* @uses $cfg['QueryHistoryMax']
* @uses $cfg['QueryHistoryDB']
* @uses $GLOBALS['controllink']
* @uses PMA_backquote()
* @uses PMA_sqlAddSlashes()
* @uses PMA_query_as_cu()
* @uses PMA_DBI_fetch_value()
* @param string $username the username
* @access public
*/
function PMA_purgeHistory($username)
{
$cfgRelation = PMA_getRelationsParam();
if (!$GLOBALS['cfg']['QueryHistoryDB'] || !$cfgRelation['historywork']) {
return;
}
if (!$cfgRelation['historywork']) {
return;
}
$search_query = '
SELECT `timevalue`
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '
WHERE `username` = \'' . PMA_sqlAddSlashes($username) . '\'
ORDER BY `timevalue` DESC
LIMIT ' . $GLOBALS['cfg']['QueryHistoryMax'] . ', 1';
if ($max_time = PMA_DBI_fetch_value($search_query, 0, 0, $GLOBALS['controllink'])) {
PMA_query_as_cu('
DELETE FROM
' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '
WHERE `username` = \'' . PMA_sqlAddSlashes($username) . '\'
AND `timevalue` <= \'' . $max_time . '\'');
}
}
示例15: PMA_getDbCollation
/**
* returns collation of given db
*
* @uses PMA_MYSQL_INT_VERSION
* @uses PMA_DBI_fetch_value()
* @uses PMA_DBI_select_db()
* @uses PMA_sqlAddSlashes()
* @uses $GLOBALS['db']
* @param string $db name of db
* @return string collation of $db
*/
function PMA_getDbCollation($db)
{
if (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema') {
// We don't have to check the collation of the virtual
// information_schema database: We know it!
return 'utf8_general_ci';
}
if (PMA_MYSQL_INT_VERSION >= 50006) {
// Since MySQL 5.0.6, we don't have to parse SHOW CREATE DATABASE anymore.
return PMA_DBI_fetch_value('SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = \'' . PMA_sqlAddSlashes($db) . '\' LIMIT 1;');
} elseif (PMA_MYSQL_INT_VERSION >= 40101) {
// MySQL 4.1.0 does not support seperate charset settings
// for databases.
PMA_DBI_select_db($db);
// the query does not work if this string is in double quotes
// and MySQL is running in ANSI mode
$return = PMA_DBI_fetch_value('SHOW VARIABLES LIKE \'collation_database\'', 0, 1);
if ($db !== $GLOBALS['db']) {
PMA_DBI_select_db($GLOBALS['db']);
}
return $return;
}
return '';
}