class db
{
function connect()
{
$lines = file('secret');
$uid = trim($lines[0]);
$pw = trim($lines[1]);
$dbserver = trim($lines[2]);
$dbname = trim($lines[3]);
$link = mysqli_connect($dbserver, $uid, $pw, $dbname) or die('Could not connect: ' . mysqli_error());
return $link;
}
function query($sql)
{
$result = mysqli_query($this->connect(), $sql) or die('query failed' . mysqli_error());
return $result;
}
function close()
{
mysqli_close($this->connect());
}
}
//任何人都可以切换这些代码以包含私有成员吗?//我尝试了很多东西,但每次都失败