久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

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

      關(guān)于php mysqli函數(shù)的一些總結(jié)和詳細(xì)介紹(五)

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

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

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

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

      一、什么是php mysqli?

      php mysqli = php nysqli improved

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

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

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

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

      有關(guān)安裝的詳細(xì)信息,請?jiān)L問:http://www.php.net/manual/en/mysqli.installation.php

      有關(guān)運(yùn)行配置的詳細(xì)信息地址:http://www.php.net/manual/en/mysqli.configuration.php

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

      1、mysqli_fetch_array()函數(shù)

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

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

      2、mysqli_fetch_assoc函數(shù)

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

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

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

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

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

      實(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_direct($result, 2); printf("字段名:%s",$fieldinfo->name); echo "<br>"; printf("數(shù)據(jù)表:%s",$fieldinfo->table); echo "<br>"; printf("最大長度:%s",$fieldinfo->max_length); //釋放結(jié)果集 mysqli_free_result($result); }  //關(guān)閉連接 mysqli_close($conn); ?>

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

      >name – 字段名

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

      >table – 字段所屬表名

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

      >def – 該字段的默認(rèn)值

      >max_length – 字段的最大寬度

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

      >charsetnr – 字段的字符集號

      >flags – 字段的位標(biāo)志

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

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

      4、mysqli_fetch_field()函數(shù)

      描述:從結(jié)果集中取得下一字段并返回相關(guān)信息。

      實(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); //釋放結(jié)果集 mysqli_free_result($result); }  //關(guān)閉連接 mysqli_close($conn); ?>

      返回對象屬性同上。

      5、mysqli_fetch_fields()函數(shù)

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

      對象屬性同上。

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

      推薦相關(guān)文章:https://www.php.cn/php-weizijiaocheng-428673.html

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