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.