650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/EE/wKiom1WLxsaRCQ6KAAC_WydWyYQ068.jpg "title=" PHP Development-Wheat Academy "alt=" Wkiom1wlxsarcq6kaac_wydwyyq068.jpg "/>
Php Development , we often use MySQL and mysqli two sets of functions, the two function set is only one letter, but the function and function is very poor, the following small series for everyone to share the differences between the two function sets.
I. the concept of MySQL and mysqli
first of all, let's see What the hell is MySQL and mysqli respectively?
1,MySQL and mysqli are the function set of PHP, and the MySQL database is not very relevant.
2, before the PHP 5 version, is generally used in php mysql function to drive the MySQL database, such as mysql_query () function, belongs to a process-oriented function.
3, after the php5 version, added the function function of mysqli, in a sense, it is the MySQL system function enhanced version, more stable more efficient and more secure, and mysql_query () corresponding to the mysqli_query (), belongs to object-oriented, the operation of the object to drive the MySQL database.
Second, the difference between MySQL and mysqli
speaking of the concept of MySQL and mysqli, let's say what the difference is:
1,MySQL is a non-holding connection function,MySQL each link will open a connected process.
2,mysqli is the permanent connection function,mysqli multiple runs mysqli will use the same connection process , thereby reducing the server overhead. Mysqli encapsulates some of the advanced operations, such as transactions, while encapsulating Many of the methods available in the DB operation process.
third,MySQL and the use of mysqli
1.mysql:
$conn = mysql_connect (' localhost ', ' user ', ' password ');// connect mysql database
mysql_select_db (' data_base '); Select Database
$result = mysql_query (' select * from Data_base ');//The Second optional parameter that specifies the open connection
$row = Mysql_fetch_row ($result))// fetch only one row of data
echo $row [0]; output The value of the first field
2,mysqli:
$conn = new mysqli (' localhost ', ' user ', ' password ', ' data_base ');// to use the new operator, the last parameter is to specify the database directly
$result = Query (' SELECT * from Data_base '), $conn
$row = $result-Fetch_row (); fetch a row of data
Echo Row[0]; output The value of the first field
iv.mysql_connect () and Mysqli_connect ()
1, using mysqli, you can pass the database name as a parameter to the Mysqli_connect () function, but also to the Mysqli constructor;
2.If you call mysqli_query () or mysqli 's Object Query () method, the connection identity is required.
The above is the PHP development,MySQL and mysqli concept and usage of the difference, I hope to beginners PHP Development you have some help.
Recommended Learning: PHP Development video Tutorial
What is the difference between MySQL and mysqli functions in PHP development?