php+mysqli uses preprocessing technology to perform database queries, mysqli preprocessing_PHP tutorial

WBOY
Release: 2016-07-13 10:08:50
Original
996 people have browsed it

php+mysqli uses preprocessing technology for database query, mysqli preprocessing

The example in this article describes how php+mysqli uses preprocessing technology to perform database queries. Share it with everyone for your reference. The details are as follows:

The code is a bit difficult and requires solid basic knowledge to be easily understood. Here is the code first:

Here is how to query the id, title, and contents values of all id>5:

Copy codeThe code is as follows:
$mysqli = new MySQLi("localhost","root","123456","liuyan");
if(!$mysqli){
die($mysqli->error);
}
//Create a predefined object?Placeholder
$sql = "select id,title,contents from news where id>?";
$mysqli_stmt = $mysqli->prepare($sql);
$id=10;
//Bind parameters
$mysqli_stmt->bind_param("i",$id);
//Bind result set
$mysqli_stmt->bind_result($id,$title,$contents);
//Execute
$mysqli_stmt->execute();
//Get the bound result set
while($mysqli_stmt->fetch()){
echo "--$id--$title--$contents--
";
}
//Close the result set
$mysqli_stmt->free_result();
$mysqli_stmt->close();
$mysqli->close();
?>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.com true http: //www.bkjia.com/PHPjc/949460.html TechArticle php+mysqli uses preprocessing technology to perform database queries, mysqli preprocessing This article describes the use of php+mysqli Preprocessing technology is a method for database query. Share it with everyone...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!