Php encapsulation mysql operations

Source: Internet
Author: User
Php encapsulation mysql operations
 Host = $ host; $ this-> name = $ name; $ this-> pass = $ pass; $ this-> table = $ table; $ this-> ut = $ ut; $ this-> connect ();} function connect () {$ link = mysql_connect ($ this-> host, $ this-> name, $ this-> pass) or die ($ this-> error (); mysql_select_db ($ this-> table, $ link) or die ("no Database ". $ this-> table); mysql_query ("set names '$ this-> ut'");} function query ($ SQL, $ type = '') {if (! ($ Query = mysql_query ($ SQL) $ this-> show ('say: ', $ SQL); return $ query;} function show ($ message = '', $ SQL = '') {if (! $ SQL) echo $ message; else echo $ message .'
'. $ SQL;} function affected_rows () {return mysql_affected_rows ();} function result ($ query, $ row) {return mysql_result ($ query, $ row );} function num_rows ($ query) {return @ mysql_num_rows ($ query);} function num_fields ($ query) {return mysql_num_fields ($ query);} function free_result ($ query) {return mysql_free_result ($ query);} function insert_id () {return mysql_insert_id ();} function fetch_row ($ query) {return my SQL _fetch_row ($ query);} function version () {return mysql_get_server_info ();} function close () {return mysql_close ();} // ================== function fn_insert ($ table, $ name, $ value) {$ this-> query ("insert into $ table ($ name) value ($ value)") ;}$ db = new mysql ('localhost', 'root ', '', 'data'," GBK ");?>

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.