: 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.