PHP MySQL pre-compilation

Source: Internet
Author: User
precompiled execution DML statements

 Query ("Set names GBK"), $sql = "INSERT INTO User1 (name,psw,email,age) VALUES (?,?,?,?)"; $mysqli _stmt = $mysqli->prepare ($sql);//binding parameter $name = "Gong"; $psw = "123"; $email = "gonziwei.sohu,com"; $age = "$mysqli" _stmt->bind_param ("SSSI", $name, $PSW, $email, $age); $b = $mysqli _stmt->execute (), if (! $b) {die ("failed". $mysqli _stmt->error); exit ();} Else{echo "Success
";} Continue adding $name = "Master programmer"; $PSW = "123"; $email = "dashi.sohu,com"; $age =; $mysqli _stmt->bind_param ("SSSI", $name, $PSW, $ email, $age), $b = $mysqli _stmt->execute (), if (! $b) {die ("failed". $mysqli _stmt->error); exit ();} Else{echo "Success
";} Continue adding $name = "programming cock wire"; $PSW = "123"; $email = "diaoshi.sohu,com"; $age =; $mysqli _stmt->bind_param ("SSSI", $name, $PSW, $email, $age), $b = $mysqli _stmt->execute (), if (! $b) {die ("failed". $mysqli _stmt->error); exit ();} Else{echo "Success
";} $mysqli->close ();? >

Precompiled execution DQL statement:

 
  Connect_error) {die ($mysqli->connect_error); exit ();} Create a predefined object and get a position$sql = "Select Id,name,email from user1 where ID >?"; $mysqli _stmt = $mysqli->prepare ($sql), $id = 5;//bind Param$mysqli_stmt->bind_param ("i", $id);//bind results$ Mysqli_stmt->bind_result ($id, $name, $email) $mysqli _stmt->execute (); while ($mysqli _stmt->fetch ()) {echo ' --$id--$name--$email
";} $mysqli _stmt->close (); $mysqli->close ();? >

The above describes the PHP MySQL pre-compilation, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.