added the final steps needed for creating the database for the user

This commit is contained in:
seek3r 2001-06-01 08:57:52 +00:00
parent d17e4d5648
commit 0c41c058d1
2 changed files with 47 additions and 2 deletions

View File

@ -75,7 +75,6 @@ class db {
/* establish connection, select database */ /* establish connection, select database */
if ( 0 == $this->Link_ID ) { if ( 0 == $this->Link_ID ) {
$this->Link_ID=mysql_pconnect($Host, $User, $Password); $this->Link_ID=mysql_pconnect($Host, $User, $Password);
if (!$this->Link_ID) { if (!$this->Link_ID) {
$this->halt("pconnect($Host, $User, \$Password) failed."); $this->halt("pconnect($Host, $User, \$Password) failed.");
@ -443,4 +442,27 @@ class db {
} }
return $return; return $return;
} }
function create_database($dbname, $adminname = "", $adminpasswd = "") {
$currentUser = $this->User;
$currentPassword = $this->Password;
$currentDatabase = $this->Database;
if ($adminname != "")
{
$this->User = $adminname;
$this->Password = $adminpasswd;
$this->Database = "mysql";
}
$this->disconnect();
$this->query("CREATE DATABASE $dbname");
$this->query("grant all on $dbname.* to $currentUser@localhost identified by '$currentPassword'");
$this->disconnect();
$this->User = $currentUser;
$this->Password = $currentPassword;
$this->Database = $currentDatabase;
$this->connect();
//return $return;
}
} }

View File

@ -321,4 +321,27 @@ class db {
} }
return $return; return $return;
} }
function create_database($dbname, $adminname = "", $adminpasswd = "") {
$currentUser = $this->User;
$currentPassword = $this->Password;
$currentDatabase = $this->Database;
if ($adminname != "")
{
$this->User = $adminname;
$this->Password = $adminpasswd;
$this->Database = "mysql";
}
$this->disconnect();
$this->query("CREATE DATABASE $dbname");
$this->query("grant all on $dbname.* to $currentUser@localhost identified by '$currentPassword'");
$this->disconnect();
$this->User = $currentUser;
$this->Password = $currentPassword;
$this->Database = $currentDatabase;
$this->connect();
//return $return;
}
} }