新聞中心
對(duì)于一個(gè)初學(xué)者來說,他們?cè)趯W(xué)習(xí)的過程中肯定要學(xué)到靈活的運(yùn)用各種PHP中與數(shù)據(jù)庫相關(guān)的函數(shù)來實(shí)現(xiàn)自己的需求?,F(xiàn)在,就讓我們一起來看看有關(guān)PHP獲取字段數(shù)據(jù)類型的方法介紹。#t#

專注于為中小企業(yè)提供網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)阜城免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上千家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
mysql_field_type()函數(shù)可獲得字段的數(shù)據(jù)類型,該函數(shù)的語法格式如下。
string mysql_field_type ( resource $result, int $field_offset )
mysql_field_type()函數(shù)類似于函數(shù)mysql_field_name(),不過mysql_field_type()函數(shù)返回的是字段的數(shù)據(jù)類型。它的參數(shù)的描述如下。
l result:mysql_query()函數(shù)執(zhí)行后返回的結(jié)果集。
l field_offset:字段的偏移量,起始值為零。
使用mysql_field_type()函數(shù)的示例代碼如下:
代碼23-12 光盤\codes\第23章\23.3\mysql_field_type.php
- < ?php
- $connection=mysql_connect("localhost",
"root","root") or die("連接服務(wù)器失敗");- mysql_select_db("sunyang",$connection)
or die("選擇數(shù)據(jù)庫失敗");- $query="select * from employee";
- $result=mysql_query($query) or die
("查詢數(shù)據(jù)失敗");- //執(zhí)行查詢
- echo mysql_field_type($result,0);
- //***個(gè)字段的數(shù)據(jù)類型
- echo "< br>";
- echo mysql_field_type($result,1);
- //第二個(gè)字段的數(shù)據(jù)類型
- echo "< br>";
- echo mysql_field_type($result,2);
- //第三個(gè)字段的數(shù)據(jù)類型
- mysql_free_result($result);
- mysql_close();
- ?>
上面代碼執(zhí)行后將把表employee中的前3個(gè)字段的數(shù)據(jù)類型輸出。
分享標(biāo)題:快速掌握PHP獲取字段數(shù)據(jù)類型技巧
網(wǎng)站地址:http://m.fisionsoft.com.cn/article/copjhph.html


咨詢
建站咨詢
