PHP mysql_field_type() ฟังก์ชัน
การระบุและการใช้งาน
mysql_field_type() ฟังก์ชันกลับมาชนิดของฟิลด์ที่ระบุในผลลัพธ์
ถ้าประสบความสำเร็จ ก็จะกลับมาชนิดของฟิลด์ที่ระบุ ถ้าล้มเหลวก็จะกลับมา false
ภาษาที่ใช้
mysql_field_type(data,field_offset)
ตัวแปร | คำอธิบาย |
---|---|
data | บริโภคข้อบังคับ。ตำแหน่งข้อมูลที่จะใช้ ตำแหน่งข้อมูลนี้มาจาก mysql_query() ผลลัพธ์ที่กลับมา |
field_offset | บริโภคข้อบังคับ。ชี้ให้เห็นว่าจากฟิลด์ไหนที่จะเริ่มกลับมา 0 ชี้ว่าฟิลด์แรก |
ตัวอย่าง
<?php $con = mysql_connect("localhost", "hello", "321"); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db("test_db",$con); $sql = "SELECT * from Person"; $result = mysql_query($sql,$con); $type = mysql_field_type($result, 0); echo $type; mysql_close($con); ?>
การออกแสดง:
string