本文整理汇总了PHP中PMA_cacheExists函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_cacheExists函数的具体用法?PHP PMA_cacheExists怎么用?PHP PMA_cacheExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_cacheExists函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCacheExists
/**
* Test if cached data is available after set
*/
public function testCacheExists()
{
$GLOBALS['server'] = 'server';
PMA_cacheSet('test_data', 5, true);
PMA_cacheSet('test_data_2', 5, true);
$this->assertTrue(PMA_cacheExists('test_data', true));
$this->assertTrue(PMA_cacheExists('test_data_2', 'server'));
$this->assertFalse(PMA_cacheExists('fake_data_2', true));
}
示例2: PMA_profilingSupported
/**
* Verifies if current MySQL server supports profiling
*
* @access public
*
* @return boolean whether profiling is supported
*/
function PMA_profilingSupported()
{
if (!PMA_cacheExists('profiling_supported', true)) {
// 5.0.37 has profiling but for example, 5.1.20 does not
// (avoid a trip to the server for MySQL before 5.0.37)
// and do not set a constant as we might be switching servers
if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 50037 && PMA_DBI_fetch_value("SHOW VARIABLES LIKE 'profiling'")) {
PMA_cacheSet('profiling_supported', true, true);
} else {
PMA_cacheSet('profiling_supported', false, true);
}
}
return PMA_cacheGet('profiling_supported', true);
}
示例3: PMA_isSuperuser
/**
* returns true (int > 0) if current user is superuser
* otherwise 0
*
* @uses $_SESSION['is_superuser'] for caching
* @uses $GLOBALS['userlink']
* @uses $GLOBALS['server']
* @uses PMA_DBI_try_query()
* @uses PMA_DBI_QUERY_STORE
* @return integer $is_superuser
*/
function PMA_isSuperuser()
{
if (PMA_cacheExists('is_superuser', true)) {
return PMA_cacheGet('is_superuser', true);
}
// with mysql extension, when connection failed we don't have
// a $userlink
if (isset($GLOBALS['userlink'])) {
$r = (bool) PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', $GLOBALS['userlink'], PMA_DBI_QUERY_STORE);
PMA_cacheSet('is_superuser', $r, true);
} else {
PMA_cacheSet('is_superuser', false, true);
}
return PMA_cacheGet('is_superuser', true);
}
示例4: PMA_analyseShowGrant
/**
* sets privilege information extracted from SHOW GRANTS result
*
* Detection for some CREATE privilege.
*
* Since MySQL 4.1.2, we can easily detect current user's grants using $userlink
* (no control user needed) and we don't have to try any other method for
* detection
*
* @todo fix to get really all privileges, not only explicitly defined for this user
* from MySQL manual: (http://dev.mysql.com/doc/refman/5.0/en/show-grants.html)
* SHOW GRANTS displays only the privileges granted explicitly to the named
* account. Other privileges might be available to the account, but they are not
* displayed. For example, if an anonymous account exists, the named account
* might be able to use its privileges, but SHOW GRANTS will not display them.
*
* @uses $_SESSION['is_create_db_priv'] for caching
* @uses $_SESSION['is_process_priv'] for caching
* @uses $_SESSION['is_reload_priv'] for caching
* @uses $_SESSION['db_to_create'] for caching
* @uses $_SESSION['dbs_where_create_table_allowed'] for caching
* @uses $GLOBALS['is_create_db_priv'] to set it
* @uses $GLOBALS['is_process_priv'] to set it
* @uses $GLOBALS['is_reload_priv'] to set it
* @uses $GLOBALS['db_to_create'] to set it
* @uses $GLOBALS['dbs_where_create_table_allowed'] to set it
* @uses $GLOBALS['server']
* @uses PMA_DBI_try_query()
* @uses PMA_DBI_fetch_row()
* @uses PMA_DBI_free_result()
* @uses PMA_DBI_getError()
* @uses PMA_unQuote()
* @uses PMA_backquote()
* @uses preg_match()
* @uses preg_replace()
* @uses substr()
* @uses strpos()
*/
function PMA_analyseShowGrant()
{
if (PMA_cacheExists('is_create_db_priv', true)) {
$GLOBALS['is_create_db_priv'] = PMA_cacheGet('is_create_db_priv', true);
$GLOBALS['is_process_priv'] = PMA_cacheGet('is_process_priv', true);
$GLOBALS['is_reload_priv'] = PMA_cacheGet('is_reload_priv', true);
$GLOBALS['db_to_create'] = PMA_cacheGet('db_to_create', true);
$GLOBALS['dbs_where_create_table_allowed'] = PMA_cacheGet('dbs_where_create_table_allowed', true);
return;
}
// defaults
$GLOBALS['is_create_db_priv'] = false;
$GLOBALS['is_process_priv'] = true;
$GLOBALS['is_reload_priv'] = false;
$GLOBALS['db_to_create'] = '';
$GLOBALS['dbs_where_create_table_allowed'] = array();
$rs_usr = PMA_DBI_try_query('SHOW GRANTS');
if (!$rs_usr) {
return;
}
$re0 = '(^|(\\\\\\\\)+|[^\\\\])';
// non-escaped wildcards
$re1 = '(^|[^\\\\])(\\\\)+';
// escaped wildcards
while ($row = PMA_DBI_fetch_row($rs_usr)) {
// extract db from GRANT ... ON *.* or GRANT ... ON db.*
$db_name_offset = strpos($row[0], ' ON ') + 4;
$show_grants_dbname = substr($row[0], $db_name_offset, strpos($row[0], '.', $db_name_offset) - $db_name_offset);
$show_grants_dbname = PMA_unQuote($show_grants_dbname, '`');
$show_grants_str = substr($row[0], 6, strpos($row[0], ' ON ') - 6);
if ($show_grants_str == 'RELOAD') {
$GLOBALS['is_reload_priv'] = true;
}
/**
* @todo if we find CREATE VIEW but not CREATE, do not offer
* the create database dialog box
*/
if ($show_grants_str == 'ALL' || $show_grants_str == 'ALL PRIVILEGES' || $show_grants_str == 'CREATE' || strpos($show_grants_str, 'CREATE,') !== false) {
if ($show_grants_dbname == '*') {
// a global CREATE privilege
$GLOBALS['is_create_db_priv'] = true;
$GLOBALS['is_reload_priv'] = true;
$GLOBALS['db_to_create'] = '';
$GLOBALS['dbs_where_create_table_allowed'][] = '*';
// @todo we should not break here, cause GRANT ALL *.*
// could be revoked by a later rule like GRANT SELECT ON db.*
break;
} else {
// this array may contain wildcards
$GLOBALS['dbs_where_create_table_allowed'][] = $show_grants_dbname;
$dbname_to_test = PMA_backquote($show_grants_dbname);
if ($GLOBALS['is_create_db_priv']) {
// no need for any more tests if we already know this
continue;
}
if (preg_match('/' . $re0 . '%|_/', $show_grants_dbname) && !preg_match('/\\\\%|\\\\_/', $show_grants_dbname) || !PMA_DBI_try_query('USE ' . preg_replace('/' . $re1 . '(%|_)/', '\\1\\3', $dbname_to_test)) && substr(PMA_DBI_getError(), 1, 4) != 1044) {
if ($GLOBALS['cfg']['SuggestDBName']) {
$GLOBALS['db_to_create'] = preg_replace('/' . $re0 . '_/', '\\1?', $show_grants_dbname);
$GLOBALS['db_to_create'] = preg_replace('/' . $re0 . '%/', '\\1...', $GLOBALS['db_to_create']);
$GLOBALS['db_to_create'] = preg_replace('/' . $re1 . '(%|_)/', '\\1\\3', $GLOBALS['db_to_create']);
}
$GLOBALS['is_create_db_priv'] = true;
//.........这里部分代码省略.........
示例5: array
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
*
* @version $Id: mysql_charsets.lib.php 30792 2010-03-05 22:55:26Z mehrwert $
* @package phpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
*
*/
if (! PMA_cacheExists('mysql_charsets_count', true)) {
$res = PMA_DBI_query('SHOW CHARACTER SET;');
$mysql_charsets = array();
while ($row = PMA_DBI_fetch_assoc($res)) {
$mysql_charsets[] = $row['Charset'];
// never used
//$mysql_charsets_maxlen[$row['Charset']] = $row['Maxlen'];
$mysql_charsets_descriptions[$row['Charset']] = $row['Description'];
}
PMA_DBI_free_result($res);
$mysql_charsets_count = count($mysql_charsets);
sort($mysql_charsets, SORT_STRING);
$mysql_collations = array_flip($mysql_charsets);
示例6: PMA_isSuperuser
/**
* returns true (int > 0) if current user is superuser
* otherwise 0
*
* @return bool Whether use is a superuser
*/
function PMA_isSuperuser()
{
if (PMA_cacheExists('is_superuser', true)) {
return PMA_cacheGet('is_superuser', true);
}
// when connection failed we don't have a $userlink
if (isset($GLOBALS['userlink'])) {
if (PMA_DRIZZLE) {
// Drizzle has no authorization by default, so when no plugin is
// enabled everyone is a superuser
// Known authorization libraries: regex_policy, simple_user_policy
// Plugins limit object visibility (dbs, tables, processes), we can
// safely assume we always deal with superuser
$r = true;
} else {
// check access to mysql.user table
$r = (bool) PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', $GLOBALS['userlink'], PMA_DBI_QUERY_STORE);
}
PMA_cacheSet('is_superuser', $r, true);
} else {
PMA_cacheSet('is_superuser', false, true);
}
return PMA_cacheGet('is_superuser', true);
}