A simple database operation class implemented in PHP

Source: Internet
Author: User
Tags bool character set connect

A simple database operation class implemented in PHP

Features to implement:

-can set the connection character set when instantiating

-Can connect to the database when instantiated

-The default database can be selected when instantiated

-Close the database when destroying objects

The code is as follows:


   -->Server = $server;
            $this->username = $username;
            $this->password = $password;
            $this->default_db = $default _db;
            Connection database $this->link = mysql_connect ($this->server, $this->username, $this->password);
            if (! $this->link) {echo ' database connect failure! ';
            //Set default database $bool = mysql_select_db ($this->default_db, $this->link);
            if (! $bool) {echo ' Select default_db failure! ';
        }//Declare destructor public function __destruct () {mysql_close ($this->link); }
    }


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.