PHP mysqli real_query()ฟังก์ชั่น
ตัวอย่าง - สไตล์เชิงวัตถุ
ดำเนินการแบบสอบถาม SQL เดียว เก็บผลลัพธ์ด้วย store_result():
<?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();
}
$mysqli -> real_query("SELECT * FROM Persons");
if ($mysqli -> field_count) {
$result = $mysqli -> store_result();
$row = $result -> fetch_row();
// Free result set
$result -> free_result();
}
$mysqli -> close();
?>
ความหมายและการใช้งาน
ฟังก์ชัน real_query() / mysqli_real_query() ดำเนินการสืบค้นข้อมูล SQL เดียว ผลลัพธ์สามารถดึงหรือจัดเก็บด้วยฟังก์ชัน store_result() หรือ use_result()
ไวยากรณ์
สไตล์เชิงวัตถุ:
$mysqli -> real_query(query)
รูปแบบขั้นตอน:
mysqli_real_query(connection, query)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
connection | Required. Specifies the MySQL connection to use |
query | Required. The query to be executed |
รายละเอียดทางเทคนิค
คืนมูลค่า: | จริงกับความสำเร็จ FALSE เมื่อล้มเหลว |
---|---|
รุ่น PHP: | 5+ |
❮ PHP MySQLi อ้างอิง