Mysqli is only available after php5. Friends who have not enabled the extension can open your php. ini configuration file. It has many new features and advantages over mysql. For more information, see
Mysqli is only available after php5. Friends who have not enabled the extension can open your php. ini configuration file. It has many new features and advantages over mysql. For more information, see
Mysqli is only available after php5. If you have not enabled the extension, you can open your php. ini configuration file.
Find the following statement:; extension = php_mysqli.dll and change it to extension = php_mysqli.dll.
Compared with mysql, mysql has many new features and advantages.
(1) Support local binding, preparation (prepare) and other syntaxes
(2) error code for executing SQL statements
(3) execute multiple SQL statements at the same time
(4) provides an object-oriented method for calling interfaces.
Next we will use a php instance to connect to the mysqli database!
Method 1: use traditional process-oriented methods
The php code is as follows:
The Code is as follows:
$ Connect = mysqli_connect ('localhost', 'root', '', 'volunteer') or die ('unale to connection ');
$ SQL = "select * from vol_msg ";
$ Result = mysqli_query ($ connect, $ SQL );
While ($ row = mysqli_fetch_row ($ result )){
Echo $ row [0];
}
?>
Method 2: Use an object-oriented method to call an interface (recommended)
The php code is as follows:
The Code is as follows:
// Create an object and open the connection. The last parameter is the selected database name.
$ Mysqli = new mysqli ('localhost', 'root', '', 'volunteer ');
// Check whether the connection is successful
If (mysqli_connect_errno ()){
// Note the new features of mysqli_connect_error ()
Die ('unable to connect! '). Mysqli_connect_error ();
}
$ SQL = "select * from vol_msg ";
// Execute SQL statements, fully object-oriented
$ Result = $ mysqli-> query ($ SQL );
While ($ row = $ result-> fetch_array ()){
Echo $ row [0];
}
?>
The running results of the above two php instances are identical. You can clearly see the advantages of using mysqli class objects to build database connections!
I don't need to talk about inserting and modifying records. Just change the SQL statement. In the next article, I will talk about the prepare interface features!