亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    關于php mysqli函數(shù)的一些總結和詳細介紹(五)

    前言:php是一門入門比較簡單的編程語言,同時php有非常多的內(nèi)置函數(shù)。所以對于這些內(nèi)置函數(shù)的理解與掌握就顯得尤為重要。接下來我們就分析php的一些內(nèi)置函數(shù)。

    后續(xù)我還會繼續(xù)為大家整理。

    推薦相關PHP視頻教程:https://www.php.cn/course/list/29/type/2.html

    關于phpMysqli函數(shù)的理解:

    一、什么是php mysqli?

    php mysqli = php nysqli improved

    mysqli函數(shù)允許您訪問數(shù)據(jù)庫服務器。

    注意!mysqli擴展用于mysqli4.1.13版本或者更新的版本。

    二、如何使用mysqli函數(shù)?

    如果要使用mysqli函數(shù)則必須在編譯php時添加對mysqli擴展的支持。

    有關安裝的詳細信息,請訪問:http://www.php.net/manual/en/mysqli.installation.php

    有關運行配置的詳細信息地址:http://www.php.net/manual/en/mysqli.configuration.php

    三、php相關函數(shù)介紹

    1、mysqli_fetch_array()函數(shù)

    描述:從結果集中取出一行作為數(shù)字數(shù)字或者關聯(lián)數(shù)組,或者兩者兼有。

    注意;該函數(shù)返回的字段名是嚴格區(qū)分大小寫的。

    2、mysqli_fetch_assoc函數(shù)

    描述:從結果集中取出一行作為關聯(lián)數(shù)組。

    注意:該函數(shù)返回的字段名嚴格區(qū)分大小寫。

    3、mysqli_fetch_field_direct(result,fieldnr)函數(shù)

    參數(shù)fieldnr為必須,規(guī)定字段號介于0和字段數(shù)-1之間。

    描述:從結果集中取出單一字段(列)的 meta-data,并作為對象返回。

    實例:

    <?php //配置數(shù)據(jù)庫信息 $localhost = 'localhost'; $username = 'zmz'; $password = '20040315'; $dbname = 'zmz'; $port = 3306;  //連接數(shù)據(jù)庫 $conn = mysqli_connect($localhost,$username,$password,$dbname,$port); //檢查連接 if(mysqli_connect_errno($conn)) { die('連接數(shù)據(jù)庫失??!'.mysqli_connect_error()); } //定義sql語句 $sql = "SELECT * FROM demo"; if($result = mysqli_query($conn, $sql)) { //獲取字段“age”的信息 $fieldinfo = mysqli_fetch_field_direct($result, 2); printf("字段名:%s",$fieldinfo->name); echo "<br>"; printf("數(shù)據(jù)表:%s",$fieldinfo->table); echo "<br>"; printf("最大長度:%s",$fieldinfo->max_length); //釋放結果集 mysqli_free_result($result); }  //關閉連接 mysqli_close($conn); ?>

    在這里要注意的是:返回值包含字段的定義信息的對象,如果沒有可用信息則返回false,這個返回對象有一下屬性。

    >name – 字段名

    >orgname – 原始字段名(如果該字段指定了別名)

    >table – 字段所屬表名

    >orgtable – 原始表名(如果指定了別名)

    >def – 該字段的默認值

    >max_length – 字段的最大寬度

    >length – 在表定義中規(guī)定的字段寬度

    >charsetnr – 字段的字符集號

    >flags – 字段的位標志

    >type – 用于字段的數(shù)據(jù)類型

    >decimals – 整數(shù)字段,小數(shù)點后的位數(shù)

    4、mysqli_fetch_field()函數(shù)

    描述:從結果集中取得下一字段并返回相關信息。

    實例:

    <?php //配置數(shù)據(jù)庫信息 $localhost = 'localhost'; $username = 'zmz'; $password = '20040315'; $dbname = 'zmz'; $port = 3306;  //連接數(shù)據(jù)庫 $conn = mysqli_connect($localhost,$username,$password,$dbname,$port); //檢查連接 if(mysqli_connect_errno($conn)) { die('連接數(shù)據(jù)庫失??!'.mysqli_connect_error()); } //定義sql語句 $sql = "SELECT * FROM demo"; if($result = mysqli_query($conn, $sql)) { //獲取字段“age”的信息 $fieldinfo = mysqli_fetch_field($result); printf("字段名:%s",$fieldinfo->name); echo "<br>"; printf("數(shù)據(jù)表:%s",$fieldinfo->table); echo "<br>"; printf("最大長度:%s",$fieldinfo->max_length); //釋放結果集 mysqli_free_result($result); }  //關閉連接 mysqli_close($conn); ?>

    返回對象屬性同上。

    5、mysqli_fetch_fields()函數(shù)

    描述:返回結果集中代表字段的對象的數(shù)組,然后輸出相關信息。

    對象屬性同上。

    以上是本次為大家介紹的一下函數(shù),希望對大家有所幫助。謝謝!

    推薦相關文章:https://www.php.cn/php-weizijiaocheng-428673.html

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號