<?phpclass dbda{public $host = "localhost";p ublic $uid = "root";p ublic $pwd = "root";p ublic $dbname = "club";/*** Give an SQL statement that returns the result of the execution * @param string $sql user-specified SQL statement * @param int $type The type of statement given by the user, 0 for adding or removing, 1 for query * @return to return the result of the query, and if the query returns a two-dimensional array, Returns TRUE or False if */function Query ($sql, $type =1) {//Build Connection object $db = new Mysqli ($this->host, $this->uid, $this- PWD, $this->dbname);//Execute SQL statement $reslut = $db->query ($sql);//extract data from result set object if ($type ==1) {return $reslut->fetch_ All ();} Else{return $reslut;}} /*** gives an SQL statement that returns the associated two-dimensional array * @param string $sql user-specified SQL statement * @param int $type The type of statement given by the user, 0 for adding or removing, 1 for query * @return to return the results of the query, If the query returns a two-dimensional array, if it is deleted or not, return True or False */function Guanquery ($sql, $type =1) {//Build Connection object $db = new Mysqli ($this->host, $this- UID, $this->pwd, $this->dbname);//Execute SQL statement $reslut = $db->query ($sql);//Fetch data if ($type ==1) {$attr = array (); while ($a = $reslut->fetch_assoc ()) {$attr [] = $a;} return $attr;} Else{return $reslut;}} /*** gives an SQL statement that returns the String * @param string $sql The user-specified SQL statement * @param int $type The type of statement given by the user, 0 for adding or deleting, 1 for query * @return to return the queryAs a result, if the query returns a string, if it is deleted or not, return True or False */function strquery ($sql, $type =1) {//Build Connection object $db = new Mysqli ($this->host, $this- >uid, $this->pwd, $this->dbname);//Execute SQL statement $reslut = $db->query ($sql);//Fetch data if ($type ==1) {$attr = $reslut- >fetch_all (); $str = "", foreach ($attr as $v) {$str. = Implode ("^", $v); $str. = "|";} Return substr ($str, 0,strlen ($STR)-1);} Else{return $reslut;}}}
My class of Dbda