My class of Dbda

Source: Internet
Author: User

<?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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.