前言:php是一門入門比較簡(jiǎn)單的編程語言,同時(shí)php有非常多的內(nèi)置函數(shù)。所以對(duì)于這些內(nèi)置函數(shù)的理解與掌握就顯得尤為重要。接下來我們就分析php的一些內(nèi)置函數(shù)。
后續(xù)我還會(huì)繼續(xù)為大家整理。
推薦相關(guān)視頻教程:https://www.php.cn/course/list/29/type/4.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í)添加對(duì)mysqli擴(kuò)展的支持。
有關(guān)安裝的詳細(xì)信息,請(qǐng)?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_debug(message)
函數(shù)
描述:用于執(zhí)行調(diào)試操作,返回true。
注意;為了使用該函數(shù),您必須編譯mysql客戶端庫來支持調(diào)試。
2、mysqli_dump_debug_info(link)
函數(shù)
描述:轉(zhuǎn)儲(chǔ)調(diào)試信息到日志中,成功返回true,失敗返回false。
3、mysqli_error_list()
函數(shù)
描述:返回最近調(diào)用函數(shù)的錯(cuò)誤列表,每一個(gè)錯(cuò)誤都帶有一個(gè)errno、error、sqlstate的關(guān)聯(lián)數(shù)組。
4、mysqli_state(connection)
函數(shù)
描述:返回當(dāng)前系統(tǒng)狀態(tài)。
實(shí)例:
<?php //配置數(shù)據(jù)庫相關(guān)信息 $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('連接失敗!'.mysqli_connect_error()); } //連接成功,返回當(dāng)前系統(tǒng)狀態(tài) echo '當(dāng)前系統(tǒng)狀態(tài)'.mysqli_stat($conn); //關(guān)閉連接 mysqli_close($conn); ?>
5、mysqli_fetch_all(result,resulttype)
函數(shù)
返回類型resulttype:
MYSQLI_ASSOC
MYSQLI_NUM
MYSQLI_BOTH
描述:從結(jié)果集取出所有行,作為關(guān)聯(lián)數(shù)組或者索引數(shù)組或者二者兼有。
實(shí)例:
<?php //配置數(shù)據(jù)庫相關(guān)信息 $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('連接失敗!'.mysqli_connect_error()); } //執(zhí)行sql語句 $sql = "SELECT * FROM demo"; $result = mysqli_query($conn, $sql); $rows = mysqli_fetch_all($result); print_r($rows); //釋放結(jié)果集 mysqli_free_result($result); //關(guān)閉連接 mysqli_close($conn); ?>
以上是本次為大家整理的phpmysqli函數(shù)介紹以及實(shí)例,希望可以幫助到大家。謝謝!
推薦相關(guān)文章:https://www.php.cn/course/list/29/type/4.html