PHP mysqli တွင်ပြင်ဆင်() လုပ်ဆောင်ချက်
ဥပမာ - Object Oriented စတိုင်
လုပ်ဆောင်ရန်အတွက် SQL ကြေညာချက်ကို ပြင်ဆင်ပါ။
<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");
// Check connection
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
exit();
}
// prepare and bind
$stmt = $mysqli -> prepare("INSERT INTO
MyGuests (firstname, lastname, email) VALUES (?, ?, ?)");
$stmt ->
bind_param("sss", $firstname, $lastname, $email);
// set parameters and
execute
$firstname
= "John";
$lastname = "Doe";
$email = "[email protected]";
$stmt -> execute();
$firstname = "Mary";
$lastname = "Moe";
$email = "[email protected]";
$stmt -> execute();
echo "New records created successfully";
$stmt -> close();
$mysqli -> close();
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
ပြင်ဆင်ခြင်း() / mysqli_prepare() လုပ်ဆောင်ချက်ကို လုပ်ဆောင်ရန်အတွက် SQL ကြေညာချက်ကို ပြင်ဆင်ရန် အသုံးပြုသည်။
အထားအသို
အရာဝတ္ထုကို ဦးတည်သည့်ပုံစံ-
$mysqli -> prepare(query)
လုပ်ထုံးလုပ်နည်းပုံစံ-
mysqli_prepare(connection, query)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
connection | Required. Specifies the MySQL connection to use |
query | Required. Specifies an SQL query. Note: Do not add semicolon to the end of the query! |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | အောင်မြင်မှုဆိုင်ရာ ကြေညာချက် ရှုံးနိမ့်မှုအပေါ် မှားသည်။ |
---|---|
PHP ဗားရှင်း- | ၅+ |
❮ PHP MySQLi အကိုးအကား