Mysqli compared to MySQL has a lot of advantages, recommend that you use, if you do not know, you can view the basics of MySQL tutorial:
MYSQLI Connection Database and mysqli preprocessing prepare used. Not only that, mysqli is more support for multiple query features, look at the following section of PHP code:
Copy Code code as follows:
<?php
$mysqli = new Mysqli ("localhost", "root", "" "," new ");
$mysqli->query ("Set names ' UTF8");
More than one SQL statement
$sql = "Select Id,name from ' user ';";
$sql. = "Select Id,mail from ' user '";
Echo $sql;
if ($mysqli->multi_query ($sql)) {//multi_query () executes one or more SQL statements
do{
if ($rs = $mysqli->store_result ()) {//store_result () method Gets the result of the first SQL statement query
while ($row = $rs->fetch_row ()) {
Var_dump ($row);
echo "<br>";
}
$rs->close (); Close result set
if ($mysqli->more_results ()) {//To determine if there are more result sets
echo "}
}
}while ($mysqli->next_result ());//next_result () method gets the next result set, returns a bool value
}
$mysqli->close (); To close a database connection
?>
With regard to some of the methods used, I have commented very clearly, especially to note that Multi_query () to execute multiple statements, between statements is used; Separated, otherwise there will be an error