- Configuring the Environment
Configuring the php.ini file to allow PHP to support mysqli extension libraries
Extension=php_mysqli.dll
- Build a database and build a table
See the blog "MySQL Extension library operation MySQL database"
1<?PHP2 //mysqli Extension Library operations MySQL database, object oriented3 $mysqli=NewMysqli ("localhost", "root", "root", "test");4 if($mysqli-connect_error) {5 die("Connection Database Failed".$mysqli-connect_error);6 }7 $sql= "SELECT * from User1";8 $res=$mysqli->query ($sql);9 while($row=$res-Fetch_row ()) {Ten foreach($row as $key=$val){ One Echo"--".$val; A } - Echo"<br/>"; - } the $res-Free (); - $mysqli-close (); -?>
The results are as follows:
- Delete and Change database
1<?PHP2 //mysqli Extension Library operations MySQL database, object oriented3 $mysqli=NewMysqli ("localhost", "root", "root", "test");4 if($mysqli-connect_error) {5 die("Connection Database Failed".$mysqli-connect_error);6 }7 //$sql = "INSERT INTO User1 (name,password,age,birthday) VALUES (' WPP ', MD5 (' WPP '), ' 1991-05-05 ')";8 //$sql = "Update user1 set age=24 where name= ' WPP '";9 $sql= "Delete from User1 where name= ' WPP '";Ten $res=$mysqli->query ($sql); One if(!$res){ A Echo"Operation failed."$mysqli-error; -}Else{ - if($mysqli->affected_rows>0){ the Echo"Operation succeeded"; -}Else{ - Echo"No rows are affected"; - } + } - $mysqli-close (); +?>
MYSQLI Extension Library operation MySQL Database