PHP---Pre-compilation

Source: Internet
Author: User

When an equivalent operation SQL statement, such as a large number of data into the database, the original type of execution of SQL statements or bulk execution of SQL statements, it is obviously not feasible, because whether it is a single execution or bulk execution will be continuous send SQL statements to the database, The database is compiled with SQL statements, resulting in efficiency.

The pre-compilation that appears in PHP solves this problem, and he works by sending SQL statements to the database to pre-compile the SQL statement. Then you just need to send the data to the database.

Here's an official example to illustrate the situation:

<?php$mysqli = new mysqli (' localhost ', ' my_user ', ' My_password ', ' world ');/* Check connection */if (mysqli_connect_ errno ()) {    printf ("Connect failed:%s\n", Mysqli_connect_error ());    Exit ();} $stmt = $mysqli->prepare ("INSERT into Countrylanguage VALUES (?,?,?,?)");


Where $mysqli->prepare is pre-compiled with SQL statements,

$stmt->bind_param is a parameter binding. The first parameter above refers to the data type of all parameters.

$stmt->execute (); is an insert operation.

If you need to insert multiple data, you only need to manipulate $stmt->bind_param and $stmt->execute ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.