1. Object-oriented usage $db = new mysqli (' localhost ', ' root ', ' 123456 ', ' dbname '), select the database to use if the database is not specified when establishing the connection, switch the database used $db->select_ db (' dbname '); $query = "SELECT * from user WHERE uid=4"; $result = $db->query ($query); $result _num = $result->num_rows ; $row = $result->fetch_assoc (); //returns an associative array that can be obtained by means of $row[' uid '] $row = $result->fetch_row ();  //Returns an enumeration array, which can be obtained by means of $row[0] $row = $result->fetch_array (); //Returns a mixed array, which can be obtained by $row[' uid ' and $row[0] in two ways $row = $result->fetch_object (); //Returns an object that can be $row->uid to get the value $result->free (); //Release result set $db->close (); //Closing a database connection is not necessary because the connection is closed automatically when the script is executed. When an INSERT, UPDATE, delete operation is performed, use $db->affected_ Rows view affects rows 2. Process-oriented usage $db = Mysqli_connect (' localhost ', ' root ', ' 123456 ', ' dbname '), and if the database is not specified when the connection is established, select the database to use. Switch the database used mysqli_select_db ($db, ' dbname '), query the database $query = "SELECT * from user WHERE uid=4"; $result = Mysqli_query ($db, $query ); $result _num = Mysqli_num_rows ($result); Returns a row of results $row = Mysqli_fetch_ASSOC ($result); //returns an associative array that can be obtained by means of $row[' uid '] $row = Mysqli_fetch_row ($result);  //Returns an enumeration array, which can be obtained by $row[0] $row = Mysqli_fetch_array ($result); //Returns a mixed array, which can be obtained by $row[' uid ' and $row[0] in two ways $row = Mysqli_fetch_object ($result); //Returns an object that can be obtained by $ROW->UID to disconnect the database connection Mysqli_free_result ($result); //Release result set Mysqli_close ($DB); //shutting down a database connection is not necessary because the connection is closed automatically when the script is executed when an INSERT, UPDATE, delete operation is performed, the number of rows affected is viewed using mysqli_affected_rows ()