国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

PHP MySQL? ?? ??? ??? ?????.

PHP MySQL ?? ??? ?? ??

MySQLi ? PDO? ???? MySQL? ?? ??? ?? ??

mysqli_multi_query() ??? ???? ?? ?? ?? SQL ?.

?? ???? "MyGuests" ???? ? ?? ? ???? ?????.

?(MySQLi - ?? ??)

<?php
 $servername = "localhost";
 $username = "username";
 $password = "password";
 $dbname = "myDB";
 
 // 創(chuàng)建鏈接
 $conn = new mysqli($servername, $username, $password, $dbname);
 // 檢查鏈接
 if ($conn->connect_error) {
     die("連接失敗: " . $conn->connect_error);
 } 
 
 $sql = "INSERT INTO MyGuests (firstname, lastname, email)
 VALUES ('John', 'Doe', 'john@example.com');";
 $sql .= "INSERT INTO MyGuests (firstname, lastname, email)
 VALUES ('Mary', 'Moe', 'mary@example.com');";
 $sql .= "INSERT INTO MyGuests (firstname, lastname, email)
 VALUES ('Julie', 'Dooley', 'julie@example.com')";
 
 if ($conn->multi_query($sql) === TRUE) {
     echo "新記錄插入成功";
 } else {
     echo "Error: " . $sql . "<br>" . $conn->error;
 }
 
 $conn->close();
 ?>

? SQL ?? No?? ???. ??.

????(MySQLi - ???? ??)

<?php
 $servername = "localhost";
 $username = "username";
 $password = "password";
 $dbname = "myDB";
 
 // 創(chuàng)建鏈接
 $conn = mysqli_connect($servername, $username, $password, $dbname);
 // 檢查鏈接
 if (!$conn) {
     die("連接失敗: " . mysqli_connect_error());
 }
 
 $sql = "INSERT INTO MyGuests (firstname, lastname, email)
 VALUES ('John', 'Doe', 'john@example.com');";
 $sql .= "INSERT INTO MyGuests (firstname, lastname, email)
 VALUES ('Mary', 'Moe', 'mary@example.com');";
 $sql .= "INSERT INTO MyGuests (firstname, lastname, email)
 VALUES ('Julie', 'Dooley', 'julie@example.com')";
 
 if (mysqli_multi_query($conn, $sql)) {
     echo "新記錄插入成功";
 } else {
     echo "Error: " . $sql . "<br>" . mysqli_error($conn);
 }
 
 mysqli_close($conn);
 ?>

????(PDO)

<?php
 $servername = "localhost";
 $username = "username";
 $password = "password";
 $dbname = "myDBPDO";
 
 try {
     $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
     // set the PDO error mode to exception
     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
     // 開始事務(wù)
     $conn->beginTransaction();
     // SQL 語句
     $conn->exec("INSERT INTO MyGuests (firstname, lastname, email) 
     VALUES ('John', 'Doe', 'john@example.com')");
     $conn->exec("INSERT INTO MyGuests (firstname, lastname, email) 
     VALUES ('Mary', 'Moe', 'mary@example.com')");
     $conn->exec("INSERT INTO MyGuests (firstname, lastname, email) 
     VALUES ('Julie', 'Dooley', 'julie@example.com')");
 
     // 提交事務(wù)
     $conn->commit();
     echo "新記錄插入成功";
 }
 catch(PDOException $e)
 {
     // 如果執(zhí)行失敗回滾
     $conn->rollback();
     echo $sql . "<br>" . $e->getMessage();
 }
 
 $conn = null;
 ?>

mysqli ???? ???? ??? ? ??

? ?? ??? ???? ???? ? ?????.

?? ???? ????? ???? ? ????.

mysql ??? ??? ?? mysql ??????? ????? ??? ?? ? ????. ??? ????? ?????? "???"? ? ????.

??(MySQLi? ??? ??? ???)

<?php
 $servername = "localhost";
 $username = "username";
 $password = "password";
 $dbname = "myDB";
 
 // 創(chuàng)建連接
 $conn = new mysqli($servername, $username, $password, $dbname);
 // 檢測連接
 if ($conn->connect_error) {
     die("連接失敗: " . $conn->connect_error);
 } else {
     $sql = "INSERT INTO MyGuests VALUES(?, ?, ?)";
 
     // 為 mysqli_stmt_prepare() 初始化 statement 對象
     $stmt = mysqli_stmt_init($conn);
 
     //預(yù)處理語句
     if (mysqli_stmt_prepare($stmt, $sql)) {
         // 綁定參數(shù)
         mysqli_stmt_bind_param($stmt, 'sss', $firstname, $lastname, $email);
 
         // 設(shè)置參數(shù)并執(zhí)行
         $firstname = 'John';
         $lastname = 'Doe';
         $email = 'john@example.com';
         mysqli_stmt_execute($stmt);
 
         $firstname = 'Mary';
         $lastname = 'Moe';
         $email = 'mary@example.com';
         mysqli_stmt_execute($stmt);
 
         $firstname = 'Julie';
         $lastname = 'Dooley';
         $email = 'julie@example.com';
         mysqli_stmt_execute($stmt);
     }
 }
 ?>

?? ???? ??? ???? ?? ???? ???? ?? ? ? ????. ?? ??? ???? ? ?? ?? ??? ? ????.

???? ???? ?????. mysqli_stmt_bind_param()? ??? ???????.

mysqli_stmt_bind_param($stmt, 'sss', $firstname, $lastname, $email);

? ??? ???? ??? ????? ????? ??????? ?????. ? ?? ????? "sss" ???. ?? ??? ???? ??? ?????. s ??? mysql?? ????? ????? ?????.

? ?? 4?? ????? ? ????.

·???????? b - ?? ?

? ????? ??? ??? ???? ?? ??? ???? ???. ?? ??? ?? SQL ?? ???? ??? ?? ? ????.

???? ??
||
<?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDB"; // 創(chuàng)建鏈接 $conn = mysqli_connect($servername, $username, $password, $dbname); // 檢查鏈接 if (!$conn) { die("連接失敗: " . mysqli_connect_error()); } $sql = "INSERT INTO MyGuests (firstname, lastname, email) VALUES ('John', 'Doe', 'john@example.com');"; $sql .= "INSERT INTO MyGuests (firstname, lastname, email) VALUES ('Mary', 'Moe', 'mary@example.com');"; $sql .= "INSERT INTO MyGuests (firstname, lastname, email) VALUES ('Julie', 'Dooley', 'julie@example.com')"; if (mysqli_multi_query($conn, $sql)) { echo "新記錄插入成功"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } mysqli_close($conn); ?>