1.MysqlClient Introduction,command line: This method is unfriendly. 2.MysqlClient IntroductionWebform of visual interface (PhpMyAdmin)
Advantage: You can operate the database as long as you have a browser
Disadvantages:
A) Create a database
b) Create a table
3.windowsform of client
4.Export of Databases
After clicking Execute, generate SQL statements and save the tables and data .
5.Import of Data
1. Create a database
2. Select the database and click Import
6.Create a database
In the project,PHP acts as a client for the Mysql database, connects to the database via PHP , and operates the database.
PHP itself is a framework, it is the function of php extension, to connect to the database through php , you must open a php Connection MySQL 's functionality, which is php 's mysql extension.
In php.ini , Remove the semicolon before Extension=php_mysql.dll and restart the server.
The Wamp integration environment is turned on by default.
Create a new database from phpMyAdmin and import the prepared SQL file into the database.
7. Connect to the database
1. by mysql_connect"in the new version with mysqli_connect"( database address, user name, password )to return a connection object for a database.
2. Terminate execution exit ([ parameter ]) or die ([ parameter ])
3. Simplify the above code with an or statement
8. Select a database
Method One: Using the mysqli_query () function
Method Two: Using the mysql_select_db () function
9. Remove the data 9.1.mysqli_fetch_row ()
When the match starts, the pointer points to the first record, takes the current record in the resource, matches the index array, and moves the pointer down one
1<?PHP2 //connecting to a database3 $link=@Mysqli_connect(' 127.0.0.1 ', ' root ', ') or die(' Database connection failed! ‘);4 //mysqli_query ($link, ' use data ') or Die (' Database selection failed! ');5 $db _selected=mysqli_select_db($link, ' data ') or die(' Database selection failed! ‘);6 Mysqli_query($link, "Set names UTF8");7 $rs=Mysqli_query($link, ' select * from student ');8 9 Ten?> One<table> A<tr> -<th> Study No. </th> -<th> name </th> the<th> Sex </th> -<th> Age </th> -<th> Address </th> -</tr> + -<?PHP + while($result=Mysqli_fetch_row($rs)) A { at //Print_r (Mysqli_fetch_row ($rs)); - Echo"<tr>"; - Echo"<th>".$result[0] "." </th> "; - Echo"<th>".$result[1] "." </th> "; - Echo"<th>".$result[2] "." </th> "; - Echo"<th>".$result[3] "." </th> "; in Echo"<th>".$result[4] "." </th> "; - Echo"</tr>"; to } +?> -</table>
Cons: The number of data fields changes, which can affect the change of the array index number in the program
9.2Take out the result set data (Mysqli_fetch_assoc)
When the match starts, the pointer points to the first record, takes the current record in the resource, matches the associative array, and moves the pointer down one
9.3Remove the result set data (Mysql_fetch_array)
When the match starts, the pointer points to the first record, the current record in the resource is fetched, and the matched array supports both associative and indexed arrays. Move the pointer down one bar
9.4Remove the result set data (Mysql_fetch_object)
Take a piece of data from the recordset, match it to an object, move the pointer down one line, a record is an object, and a field is an attribute
Invoking the properties of an object in PHP with the symbol
10. Releasing Resources
11. Close the connection
Operation of Database in PHP