In the newly downloaded PHP5 you will find one more mysqli.dll, what is it used for? I simply introduce ...
Mysqli.dll is an extended support for PHP's new features for MySQL. can be loaded in php.ini in PHP5.
MySQL behind I, refers to improved, interface, ingenious, incompatible or incomplete (the extension is still in development because of MYSQL4.) 1 and MYSQL5 are not officially launched yet in development, new features are not fully implemented.
Mysqli want to achieve the specific objectives are:
-Simpler Maintenance
-Better compatibility
-Backward compatibility
MySQL (refers to the module in PHP) has developed to appear more messy, it is necessary to redo the next collation. At the same time, it is necessary to keep up with the pace of development of MySQL (DBMS), add new features to support, and adapt to MySQL (DBMS) later versions. So Mysqli.dll was born.
Characteristics of Mysqli.dll:
-can be used in the same way as Mysql.dll
-OO interface support, simple call
-Support MYSQL4. 1 Introduction of new features
-You can set advanced connection options by using related functions such as mysqli_init ()
Examples of the use of mysqli:
1. The same way as before Mysql.dll:
Copy Code code as follows:
<?php
/* Connect to a MySQL server * *
$link = Mysqli_connect (
' localhost ',/* The host to connect to/*
' User ',/* The user to connect AS/*
' Password ',/* The password to use * *
' World '); /* The default table to query * *
if (! $link) {
printf ("Can" T connect to MySQL Server.) ErrorCode:%sn ", Mysqli_connect_error ());
Exit
}
* Send a query to the server * *
if ($result = Mysqli_query ($link, ' SELECT Name, Population from-Population DESC LIMIT 5 ')) {
Print ("Very Large Cities Are:n");
* * Fetch The results of the query * * *
while ($row = Mysqli_fetch_assoc ($result)) {
printf ("%s (%s) n", $row [' Name '], $row [' Population ']);
}
/* Destroy The "result set" and free "memory used for it * *
Mysqli_free_result ($result);
}
/* Close the connection * *
Mysqli_close ($link);
?>
Output results:
Very Large cities are:
Mumbai (Bombay) (10500000)
Seoul (9981619)
São Paulo (9968485)
Shanghai (9696300)
Jakarta (9604900)
2. Use the built-in Oo interface method to invoke:
Copy Code code as follows:
<?php
/* Connect to a MySQL server * *
$mysqli = new mysqli (' localhost ', ' user ', ' Password ', ' World ');
if (Mysqli_connect_errno ()) {
printf ("Can" T connect to MySQL Server.) ErrorCode:%sn ", Mysqli_connect_error ());
Exit
}
* Send a query to the server * *
if ($result = $mysqli->query (' SELECT Name, Population from-Population DESC LIMIT 5 ')) {
Print ("Very Large Cities Are:n");
* * Fetch The results of the query * * *
while ($row = $result->fetch_assoc ()) {
printf ("%s (%s) n", $row [' Name '], $row [' Population ']);
}
/* Destroy The "result set" and free "memory used for it * *
$result->close ();
}
/* Close the connection * *
$mysqli->close ();
?>
The new features supported are: Bound parameters,bound results ...
Interested can go directly to the original English:
Http://www.zend.com/php5/articles/php5-mysqli.php#fn3
Note: Feeling this is not useful for everyone. But... Believe can help us to understand more "change", can better grasp "trend" 8-)