Mysqli class (no transaction pre-compilation)

Source: Internet
Author: User
: This article mainly introduces the mysqli class (no transaction pre-compilation). If you are interested in the PHP Tutorial, refer to it.
 Host = isset ($ arr ['host'])? $ Arr ['host']: 'localhost'; $ this-> user = isset ($ arr ['$ password'])? $ Arr ['user']: 'root'; $ this-> password = isset ($ arr ['password'])? $ Arr ['password']: '000000'; $ this-> charset = isset ($ arr ['charset'])? $ Arr ['charset']: 'utf8'; $ this-> dbname = isset ($ arr ['dbname'])? $ Arr ['dbname']: 'project'; $ this-> mysqli = new mysqli ($ this-> host, $ this-> user, $ this-> password, $ this-> dbname) ;}# private function exec ($ SQL) {if (! ($ This-> mysqli-> query ($ SQL) {die ($ this-> mysqli-> error ); # Error handling} return $ this-> mysqli-> query ($ SQL);} # data operation public function db_delete ($ SQL) {$ this-> exec ($ SQL); echo "your SQL statement is incorrect:
"; # Execute exec () return $ this-> mysqli-> affected_rows; # obtain the number of affected rows} # data update operation public function db_update ($ SQL) {$ this-> exec ($ SQL); # execute exec () return $ this-> mysqli-> affected_rows; # Getting affected rows} # insert public function db_insert ($ SQL) {$ res = $ this-> exec ($ SQL); # execute exec () return $ this-> mysqli-> affected_rows; # obtain the number of affected rows} # obtain a single data entry public function db_getOne ($ SQL) {$ res = $ this-> exec ($ SQL); return $ res = $ res-> fetch_assoc () ;}# retrieve multiple pieces of data public function db_getAll ($ SQL) {$ res = $ this-> exec ($ SQL); return $ res-> fetch_all ();}}

The above introduces the mysqli class (no transaction pre-compilation), including some content, hope to be helpful to friends who are interested in PHP tutorials.

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.