本文整理汇总了PHP中PMA_addUser函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_addUser函数的具体用法?PHP PMA_addUser怎么用?PHP PMA_addUser使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_addUser函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPMAAddUser
/**
* Test for PMA_addUser
*
* @return void
*/
public function testPMAAddUser()
{
$dbname = 'pma_dbname';
$username = 'pma_username';
$hostname = 'pma_hostname';
$_REQUEST['adduser_submit'] = true;
$_POST['pred_username'] = 'any';
$_POST['pred_hostname'] = 'localhost';
$_POST['pred_password'] = 'keep';
$_REQUEST['createdb-3'] = true;
$_REQUEST['userGroup'] = "username";
$_REQUEST['authentication_plugin'] = 'mysql_native_password';
list($ret_message, , , $sql_query, $_add_user_error) = PMA_addUser($dbname, $username, $hostname, $dbname, true);
$this->assertEquals('You have added a new user.', $ret_message->getMessage());
$this->assertEquals("CREATE USER ''@'localhost' IDENTIFIED WITH mysql_native_password AS '***';" . "GRANT USAGE ON *.* TO ''@'localhost' REQUIRE NONE;" . "GRANT ALL PRIVILEGES ON `pma_dbname`.* TO ''@'localhost';", $sql_query);
$this->assertEquals(false, $_add_user_error);
}
示例2: list
* only to update the password
*/
if (isset($_REQUEST['change_copy']) && $username == $_REQUEST['old_username'] && $hostname == $_REQUEST['old_hostname']) {
$response->addHTML(PMA_Message::error(__('Username and hostname didn\'t change.'))->getDisplay());
$response->isSuccess(false);
exit;
}
/**
* Changes / copies a user, part I
*/
list($queries, $password) = PMA_getDataForChangeOrCopyUser();
/**
* Adds a user
* (Changes / copies a user, part II)
*/
list($ret_message, $ret_queries, $queries_for_display, $sql_query, $_add_user_error) = PMA_addUser(isset($dbname) ? $dbname : null, isset($username) ? $username : null, isset($hostname) ? $hostname : null, isset($password) ? $password : null, $cfgRelation['menuswork']);
//update the old variables
if (isset($ret_queries)) {
$queries = $ret_queries;
unset($ret_queries);
}
if (isset($ret_message)) {
$message = $ret_message;
unset($ret_message);
}
/**
* Changes / copies a user, part III
*/
if (isset($_REQUEST['change_copy'])) {
$queries = PMA_getDbSpecificPrivsQueriesForChangeOrCopyUser($queries, $username, $hostname);
}
示例3: testPMAAddUser
/**
* Test for PMA_addUser
*
* @return void
*/
public function testPMAAddUser()
{
// Case 1 : Test with Newer version
$restoreMySQLVersion = "PMANORESTORE";
if (! PMA_HAS_RUNKIT) {
$this->markTestSkipped(
'Cannot redefine constant. Missing runkit extension'
);
} else {
$restoreMySQLVersion = PMA_MYSQL_INT_VERSION;
runkit_constant_redefine('PMA_MYSQL_INT_VERSION', 50706);
}
$dbname = 'pma_dbname';
$username = 'pma_username';
$hostname = 'pma_hostname';
$_REQUEST['adduser_submit'] = true;
$_POST['pred_username'] = 'any';
$_POST['pred_hostname'] = 'localhost';
$_POST['pred_password'] = 'keep';
$_REQUEST['createdb-3'] = true;
$_REQUEST['userGroup'] = "username";
$_REQUEST['authentication_plugin'] = 'mysql_native_password';
list(
$ret_message,,, $sql_query,
$_add_user_error
) = PMA_addUser(
$dbname,
$username,
$hostname,
$dbname,
true
);
$this->assertEquals(
'You have added a new user.',
$ret_message->getMessage()
);
$this->assertEquals(
"CREATE USER ''@'localhost' IDENTIFIED WITH mysql_native_password AS '***';"
. "GRANT USAGE ON *.* TO ''@'localhost' REQUIRE NONE;"
. "GRANT ALL PRIVILEGES ON `pma_dbname`.* TO ''@'localhost';",
$sql_query
);
$this->assertEquals(
false,
$_add_user_error
);
if ($restoreMySQLVersion !== "PMANORESTORE") {
runkit_constant_redefine('PMA_MYSQL_INT_VERSION', $restoreMySQLVersion);
}
// Case 2 : Test with older versions
$restoreMySQLVersion = "PMANORESTORE";
if (! PMA_HAS_RUNKIT) {
$this->markTestSkipped(
'Cannot redefine constant. Missing runkit extension'
);
} else {
$restoreMySQLVersion = PMA_MYSQL_INT_VERSION;
runkit_constant_redefine('PMA_MYSQL_INT_VERSION', 50506);
}
list(
$ret_message,,, $sql_query,
$_add_user_error
) = PMA_addUser(
$dbname,
$username,
$hostname,
$dbname,
true
);
$this->assertEquals(
'You have added a new user.',
$ret_message->getMessage()
);
$this->assertEquals(
"CREATE USER ''@'localhost';"
. "GRANT USAGE ON *.* TO ''@'localhost' REQUIRE NONE;"
. "SET PASSWORD FOR ''@'localhost' = '***';"
. "GRANT ALL PRIVILEGES ON `pma_dbname`.* TO ''@'localhost';",
$sql_query
);
$this->assertEquals(
false,
$_add_user_error
);
if ($restoreMySQLVersion !== "PMANORESTORE") {
runkit_constant_redefine('PMA_MYSQL_INT_VERSION', $restoreMySQLVersion);
}
//.........这里部分代码省略.........
示例4: list
}
/**
* Changes / copies a user, part I
*/
list($queries, $password) = PMA_getDataForChangeOrCopyUser();
/**
* Adds a user
* (Changes / copies a user, part II)
*/
list($ret_message, $ret_queries, $queries_for_display, $sql_query, $_add_user_error)
= PMA_addUser(
isset($dbname)? $dbname : null,
isset($username)? $username : null,
isset($hostname)? $hostname : null,
isset($password)? $password : null,
$cfgRelation['menuswork']
);
//update the old variables
if (isset($ret_queries)) {
$queries = $ret_queries;
unset($ret_queries);
}
if (isset($ret_message)) {
$message = $ret_message;
unset($ret_message);
}
/**
* Changes / copies a user, part III
示例5: testPMAAddUser
/**
* Test for PMA_addUser
*
* @return void
*/
public function testPMAAddUser()
{
$dbname = 'pma_dbname';
$username = 'pma_username';
$hostname = 'pma_hostname';
$tablename = 'pma_tablename';
$password = 'pma_password';
$_REQUEST['adduser_submit'] = true;
$_POST['pred_username'] = 'any';
$_POST['pred_hostname'] = 'localhost';
$_REQUEST['createdb-3'] = true;
$_REQUEST['userGroup'] = "username";
list($ret_message, $ret_queries, $queries_for_display, $sql_query, $_add_user_error) = PMA_addUser($dbname, $username, $hostname, $dbname, true);
$this->assertEquals('You have added a new user.', $ret_message->getMessage());
$this->assertEquals("CREATE USER ''@'localhost';GRANT USAGE ON *.* TO ''@'localhost';" . "GRANT ALL PRIVILEGES ON `pma_dbname`.* TO ''@'localhost';", $sql_query);
$this->assertEquals(false, $_add_user_error);
}