本文整理汇总了PHP中PMA_DBI_QUERY函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_DBI_QUERY函数的具体用法?PHP PMA_DBI_QUERY怎么用?PHP PMA_DBI_QUERY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_DBI_QUERY函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_DBI_free_result
PMA_DBI_free_result($res);
$res = PMA_DBI_query(
'SELECT `Db`, `Table_name`, `Table_priv` FROM `mysql`.`tables_priv`' . $user_host_condition,
$GLOBALS['userlink'],
PMA_DBI_QUERY_STORE
);
while ($row = PMA_DBI_fetch_assoc($res)) {
$res2 = PMA_DBI_QUERY(
'SELECT `Column_name`, `Column_priv`'
.' FROM `mysql`.`columns_priv`'
.' WHERE `User`'
.' = \'' . PMA_sqlAddSlashes($old_username) . "'"
.' AND `Host`'
.' = \'' . PMA_sqlAddSlashes($old_hostname) . '\''
.' AND `Db`'
.' = \'' . PMA_sqlAddSlashes($row['Db']) . "'"
.' AND `Table_name`'
.' = \'' . PMA_sqlAddSlashes($row['Table_name']) . "'"
.';',
null,
PMA_DBI_QUERY_STORE
);
$tmp_privs1 = PMA_extractPrivInfo($row);
$tmp_privs2 = array(
'Select' => array(),
'Insert' => array(),
'Update' => array(),
'References' => array()
);
示例2: unset
unset($res, $real_sql_query);
}
}
/**
* Changes / copies a user, part III
*/
if (!empty($change_copy)) {
$user_host_condition = ' WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($old_username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($old_hostname, 'quoted') . ';';
$res = PMA_DBI_query('SELECT * FROM `mysql`.`db`' . $user_host_condition);
while ($row = PMA_DBI_fetch_assoc($res)) {
$queries[] = 'GRANT ' . join(', ', PMA_extractPrivInfo($row)) . ' ON `' . $row['Db'] . '`.*' . ' TO \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\'' . ($row['Grant_priv'] == 'Y' ? ' WITH GRANT OPTION;' : ';');
}
PMA_DBI_free_result($res);
$res = PMA_DBI_query('SELECT `Db`, `Table_name`, `Table_priv`' . ' FROM `mysql`.`tables_priv`' . $user_host_condition, $GLOBALS['userlink'], PMA_DBI_QUERY_STORE);
while ($row = PMA_DBI_fetch_assoc($res)) {
$res2 = PMA_DBI_QUERY('SELECT `Column_name`, `Column_priv`' . ' FROM `mysql`.`columns_priv`' . ' WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($old_username), 'quoted') . ' AND ' . PMA_convert_using('`Host`') . ' = ' . PMA_convert_using($old_hostname, 'quoted') . ' AND ' . PMA_convert_using('`Db`') . ' = ' . PMA_convert_using($row['Db'], 'quoted') . ' AND ' . PMA_convert_using('`Table_name`') . ' = ' . PMA_convert_using($row['Table_name'], 'quoted') . ';', NULL, PMA_DBI_QUERY_STORE);
$tmp_privs1 = PMA_extractPrivInfo($row);
$tmp_privs2 = array('Select' => array(), 'Insert' => array(), 'Update' => array(), 'References' => array());
while ($row2 = PMA_DBI_fetch_assoc($res2)) {
$tmp_array = explode(',', $row2['Column_priv']);
if (in_array('Select', $tmp_array)) {
$tmp_privs2['Select'][] = $row2['Column_name'];
}
if (in_array('Insert', $tmp_array)) {
$tmp_privs2['Insert'][] = $row2['Column_name'];
}
if (in_array('Update', $tmp_array)) {
$tmp_privs2['Update'][] = $row2['Column_name'];
}
if (in_array('References', $tmp_array)) {
$tmp_privs2['References'][] = $row2['Column_name'];
示例3: PMA_getTablePrivsQueriesForChangeOrCopyUser
/**
* Get queries for Table privileges to change or copy user
*
* @param string $user_host_condition user host condition to select relevent table privileges
* @param array $queries queries array
* @param string $username username
* @param string $hostname host name
*
* @return array $queries
*/
function PMA_getTablePrivsQueriesForChangeOrCopyUser($user_host_condition, $queries, $username, $hostname)
{
$res = PMA_DBI_query('SELECT `Db`, `Table_name`, `Table_priv` FROM `mysql`.`tables_priv`' . $user_host_condition, $GLOBALS['userlink'], PMA_DBI_QUERY_STORE);
while ($row = PMA_DBI_fetch_assoc($res)) {
$res2 = PMA_DBI_QUERY('SELECT `Column_name`, `Column_priv`' . ' FROM `mysql`.`columns_priv`' . ' WHERE `User`' . ' = \'' . PMA_Util::sqlAddSlashes($_REQUEST['old_username']) . "'" . ' AND `Host`' . ' = \'' . PMA_Util::sqlAddSlashes($_REQUEST['old_username']) . '\'' . ' AND `Db`' . ' = \'' . PMA_Util::sqlAddSlashes($row['Db']) . "'" . ' AND `Table_name`' . ' = \'' . PMA_Util::sqlAddSlashes($row['Table_name']) . "'" . ';', null, PMA_DBI_QUERY_STORE);
$tmp_privs1 = PMA_extractPrivInfo($row);
$tmp_privs2 = array('Select' => array(), 'Insert' => array(), 'Update' => array(), 'References' => array());
while ($row2 = PMA_DBI_fetch_assoc($res2)) {
$tmp_array = explode(',', $row2['Column_priv']);
if (in_array('Select', $tmp_array)) {
$tmp_privs2['Select'][] = $row2['Column_name'];
}
if (in_array('Insert', $tmp_array)) {
$tmp_privs2['Insert'][] = $row2['Column_name'];
}
if (in_array('Update', $tmp_array)) {
$tmp_privs2['Update'][] = $row2['Column_name'];
}
if (in_array('References', $tmp_array)) {
$tmp_privs2['References'][] = $row2['Column_name'];
}
}
if (count($tmp_privs2['Select']) > 0 && !in_array('SELECT', $tmp_privs1)) {
$tmp_privs1[] = 'SELECT (`' . join('`, `', $tmp_privs2['Select']) . '`)';
}
if (count($tmp_privs2['Insert']) > 0 && !in_array('INSERT', $tmp_privs1)) {
$tmp_privs1[] = 'INSERT (`' . join('`, `', $tmp_privs2['Insert']) . '`)';
}
if (count($tmp_privs2['Update']) > 0 && !in_array('UPDATE', $tmp_privs1)) {
$tmp_privs1[] = 'UPDATE (`' . join('`, `', $tmp_privs2['Update']) . '`)';
}
if (count($tmp_privs2['References']) > 0 && !in_array('REFERENCES', $tmp_privs1)) {
$tmp_privs1[] = 'REFERENCES (`' . join('`, `', $tmp_privs2['References']) . '`)';
}
$queries[] = 'GRANT ' . join(', ', $tmp_privs1) . ' ON ' . PMA_Util::backquote($row['Db']) . '.' . PMA_Util::backquote($row['Table_name']) . ' TO \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\'' . (in_array('Grant', explode(',', $row['Table_priv'])) ? ' WITH GRANT OPTION;' : ';');
}
return $queries;
}
示例4: PMA_displayPrivTable
/**
* Displays the privileges form table
*
* @param string the database
* @param string the table
* @param boolean wheather to display the submit button or not
* @param int the indenting level of the code
*
* @global array the phpMyAdmin configuration
* @global ressource the database connection
*
* @return void
*/
function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = 0)
{
global $cfg, $userlink, $url_query, $checkall;
if ($db == '*') {
$table = '*';
}
$spaces = '';
for ($i = 0; $i < $indent; $i++) {
$spaces .= ' ';
}
if (isset($GLOBALS['username'])) {
$username = $GLOBALS['username'];
$hostname = $GLOBALS['hostname'];
if ($db == '*') {
$sql_query = 'SELECT * FROM `user` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ';';
} else {
if ($table == '*') {
$sql_query = 'SELECT * FROM `db` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ' AND ' . PMA_convert_using('Db') . ' = ' . PMA_convert_using($db, 'quoted') . ';';
} else {
$sql_query = 'SELECT `Table_priv` FROM `tables_priv` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ' AND ' . PMA_convert_using('Db') . ' = ' . PMA_convert_using($db, 'quoted') . ' AND ' . PMA_convert_using('Table_name') . ' = ' . PMA_convert_using($table, 'quoted') . ';';
}
}
$res = PMA_DBI_query($sql_query);
$row = PMA_DBI_fetch_assoc($res);
PMA_DBI_free_result($res);
}
if (empty($row)) {
if ($table == '*') {
if ($db == '*') {
$sql_query = 'SHOW COLUMNS FROM `mysql`.`user`;';
} else {
if ($table == '*') {
$sql_query = 'SHOW COLUMNS FROM `mysql`.`db`;';
}
}
$res = PMA_DBI_query($sql_query);
while ($row1 = PMA_DBI_fetch_row($res)) {
if (substr($row1[0], 0, 4) == 'max_') {
$row[$row1[0]] = 0;
} else {
$row[$row1[0]] = 'N';
}
}
PMA_DBI_free_result($res);
} else {
$row = array('Table_priv' => '');
}
}
if (isset($row['Table_priv'])) {
$res = PMA_DBI_query('SHOW COLUMNS FROM `tables_priv` LIKE \'Table_priv\';', $userlink);
$row1 = PMA_DBI_fetch_assoc($res);
PMA_DBI_free_result($res);
$av_grants = explode('\',\'', substr($row1['Type'], strpos($row1['Type'], '(') + 2, strpos($row1['Type'], ')') - strpos($row1['Type'], '(') - 3));
unset($res, $row1);
$users_grants = explode(',', $row['Table_priv']);
foreach ($av_grants as $current_grant) {
$row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N';
}
unset($row['Table_priv'], $current_grant, $av_grants, $users_grants);
$res = PMA_DBI_try_query('SHOW COLUMNS FROM `' . $db . '`.`' . $table . '`;');
$columns = array();
if ($res) {
while ($row1 = PMA_DBI_fetch_row($res)) {
$columns[$row1[0]] = array('Select' => FALSE, 'Insert' => FALSE, 'Update' => FALSE, 'References' => FALSE);
}
PMA_DBI_free_result($res);
}
unset($res, $row1);
}
if (!empty($columns)) {
$res = PMA_DBI_QUERY('SELECT `Column_name`, `Column_priv` FROM `columns_priv` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ' AND ' . PMA_convert_using('Db') . ' = ' . PMA_convert_using($db, 'quoted') . ' AND ' . PMA_convert_using('Table_name') . ' = ' . PMA_convert_using($table, 'quoted') . ';');
while ($row1 = PMA_DBI_fetch_row($res)) {
$row1[1] = explode(',', $row1[1]);
foreach ($row1[1] as $current) {
$columns[$row1[0]][$current] = TRUE;
}
}
PMA_DBI_free_result($res);
unset($res);
unset($row1);
unset($current);
echo $spaces . '<input type="hidden" name="grant_count" value="' . count($row) . '" />' . "\n" . $spaces . '<input type="hidden" name="column_count" value="' . count($columns) . '" />' . "\n" . $spaces . '<table border="0" cellpadding="2" cellspacing="1">' . "\n" . $spaces . ' <tr>' . "\n" . $spaces . ' <th colspan="6"> ' . $GLOBALS['strTblPrivileges'] . ' </th>' . "\n" . $spaces . ' </tr>' . "\n" . $spaces . ' <tr>' . "\n" . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="6"><small><i>' . $GLOBALS['strEnglishPrivileges'] . '</i></small></td>' . "\n" . $spaces . ' </tr>' . "\n" . $spaces . ' <tr>' . "\n" . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '"> <tt><dfn title="' . $GLOBALS['strPrivDescSelect'] . '">SELECT</dfn></tt> </td>' . "\n" . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '"> <tt><dfn title="' . $GLOBALS['strPrivDescInsert'] . '">INSERT</dfn></tt> </td>' . "\n" . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '"> <tt><dfn title="' . $GLOBALS['strPrivDescUpdate'] . '">UPDATE</dfn></tt> </td>' . "\n" . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '"> <tt><dfn title="' . $GLOBALS['strPrivDescReferences'] . '">REFERENCES</dfn></tt> </td>' . "\n";
list($current_grant, $current_grant_value) = each($row);
while (in_array(substr($current_grant, 0, strlen($current_grant) - 5), array('Select', 'Insert', 'Update', 'References'))) {
list($current_grant, $current_grant_value) = each($row);
}
echo $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="checkbox"' . (empty($checkall) ? '' : ' checked="checked"') . ' name="' . $current_grant . '" id="checkbox_' . $current_grant . '" value="Y" ' . ($current_grant_value == 'Y' ? 'checked="checked" ' : '') . 'title="' . (isset($GLOBALS['strPrivDesc' . substr($current_grant, 0, strlen($current_grant) - 5)]) ? $GLOBALS['strPrivDesc' . substr($current_grant, 0, strlen($current_grant) - 5)] : $GLOBALS['strPrivDesc' . substr($current_grant, 0, strlen($current_grant) - 5) . 'Tbl']) . '"/></td>' . "\n" . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="checkbox_' . $current_grant . '"><tt><dfn title="' . (isset($GLOBALS['strPrivDesc' . substr($current_grant, 0, strlen($current_grant) - 5)]) ? $GLOBALS['strPrivDesc' . substr($current_grant, 0, strlen($current_grant) - 5)] : $GLOBALS['strPrivDesc' . substr($current_grant, 0, strlen($current_grant) - 5) . 'Tbl']) . '">' . strtoupper(substr($current_grant, 0, strlen($current_grant) - 5)) . '</dfn></tt></label></td>' . "\n" . $spaces . ' </tr>' . "\n" . $spaces . ' <tr>' . "\n";
//.........这里部分代码省略.........