<! DOCTYPE html>
<meta charset= "Utf-8"/>
<title></title>
<body>
<?php
Class dbda{
Public $host = "localhost";
Public $uid = "root";
Public $pwd = "";
Public $dbname = "Lianxi";
/*
Query method: Executes the user-given SQL statement and returns the corresponding result
$SQL: SQL statement that the user needs to execute
$type: The type of SQL statement that the user needs to execute
Return: Returns TRUE or False if the query returns a two-dimensional array if it is added or deleted
*/
Public Function query ($sql, $type =0) {
$db = new Mysqli ($this->host, $this->uid, $this->pwd, $this->dbname);
if (Mysqli_connect_error ()) {
Return "Connection Failed! ";
}
$result = $db->query ($sql);
if ($type) {
return $result;
}else{
return $result->fetch_all ();
}
}
Public Function Strqurey ($sql, $type) {
$db = new Mysqli ($this->host, $this->uid, $this->pwd, $this->dbname);
if (Mysqli_connect_error ()) {
Return "Connection Failed! ";
}
$result = $db->query ($sql);
if ($type) {
return $result;
}else{
return $result->fetch_all ();
$str = "";
foreach ($arr as $v) {
$str = $str. Implode ("^", $v). "|";
}
$str =substr ($str, 0,strlen ($STR)-1);
return $str;
}
}
}
?>
</body>
Connecting the database returns the class of arrays and strings