No details about MySQL? PhpclassMysql {private $ host; private $ user; private $ pwd; private $ dbName; private $ charset; private $ connnull; publicfunction _ construct () {$ this-hostlocalhost; $ this-userroot; $ this-pwdroot; $ this-dbName
No details about MySQL? Php class Mysql {private $ host; private $ user; private $ pwd; private $ dbName; private $ charset; private $ conn = null; public function _ construct () {$ this-host = 'localhost'; $ this-user = 'root'; $ this-pwd = 'root'; $ this-dbName =
<无详细内容> MySQL
Host = 'localhost'; $ this-> user = 'root'; $ this-> pwd = 'root'; $ this-> dbName = 'test '; $ this-> connect ($ this-> host, $ this-> user, $ this-> pwd); $ this-> switchDb ($ this-> dbName ); $ this-> setChar ($ this-> charset);} // link to private function connect ($ h, $ u, $ p) {$ conn = mysql_connect ($ h, $ u, $ p); $ this-> conn = $ conn;} // switch the public function switchDb ($ db) {$ SQL = 'use '. $ db; $ this-> query ($ SQL);} // sets the character set public function setCh. Ar ($ char) {$ SQL = 'set names '. $ char; $ this-> query ($ SQL);} // sends an SQL query public function query ($ SQL) {return mysql_query ($ SQL, $ this-> conn);} // obtains the select result of multiple rows and multiple columns. public function getAll ($ SQL) {$ list = array (); $ rs = $ this-> query ($ SQL); if (! $ Rs) {return false;} while ($ row = mysql_fetch_assoc ($ rs) {$ list [] = $ row;} return $ list ;} public function getRow ($ SQL) {$ rs = $ this-> query ($ SQL); if (! $ Rs) {return false;} return mysql_fetch_assoc ($ rs);} public function getOne ($ SQL) {$ rs = $ this-> query ($ SQL); if (! $ Rs) {return false;} return mysql_fetch_assoc ($ rs); return $ row [0];} public function close () {mysql_close ($ this-> conn );}} echo''; $ Mysql = new Mysql (); print_r ($ mysql); $ SQL = "insert into stu values (4, 'wangwu', '123 ')"; if ($ mysql-> query ($ SQL) {echo "query succeeded";} else {echo "failed";} echo"
"; $ SQL =" select * from stu "; $ arr = $ mysql-> getAll ($ SQL); print_r ($ arr);?>