PHP tool-type MySQL add, delete, modify, and query tool-type mysql
? Php header ("content-type: text/html; charset = UTF-8 "); class DBUtils {/*** General update method insert update delete operation * @ param SQL * @ return bool true false */public function update ($ SQL) {$ link = $ this-> getConn (); mysql_query ($ SQL); // if an error is displayed, if (DEBUG) {echo mysql_error ();} $ rs = mysql_affected_rows ($ link); $ rs = $ rs> 0; mysql_close ($ link); return $ rs ;} /*** select Operation for common Query Method * @ param SQL * @ return array */public Function queryRows ($ SQL) {// create a connection, code, database $ link = $ this-> getConn (); // send SQL $ rs = mysql_query ($ SQL ); // if an error is displayed, if (DEBUG) {echo mysql_error () ;}$ rows = array (); while ($ row = mysql_fetch_array ($ rs )) {$ rows [] = $ row; // pdemo7.php} // mysql_free_result ($ rs); mysql_close ($ link); return $ rows ;} /*** common query method: select Operation query result: a row of Data * @ param SQL * @ return array returns false if the query fails. */public function queryRow ($ SQL) {$ rs = $ This-> queryRows ($ SQL); if (! Empty ($ rs [0]) {return $ rs [0];} return false ;} /*** common query method: select Operation query result: a data * @ param SQL * @ return array returns false if the query fails. * example: select count (*) from user; */public function queryObj ($ SQL) {$ rs = $ this-> queryRows ($ SQL); // var_dump ($ rs); if (! Empty ($ rs [0] [0]) {return $ rs [0] [0];} return false;} private function getConn () {$ link = mysql_connect ('2017. 0.0.1 ', 'root', ''); mysql_query (" set names utf8 "); mysql_select_db (" news "); return $ link ;}}