国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

簡單介紹下 PHP5 中引入的 MYSQLI

2024-07-24 12:56:30
字體:
來源:轉載
供稿:網友

在新下載的php5中你會發現多了一個mysqli.dll,它是干什么用的呢?我簡單介紹下。。。

mysqli.dll是php對mysql新特性的一個擴展支持。在php5中可以在php.ini中加載,如下圖:




mysql后面的i,指improved, interface, ingenious, incompatible or incomplete(改擴展仍在開發中,因為mysql4。1和mysql5都沒有正式推出尚在開發中,新的特性沒有完全實現)

mysqli想實現的目標具體有:


-更簡單的維護
-更好的兼容性
-向后兼容

mysql(指php中的模塊)發展到現在顯得比較凌亂,有必要重新做下整理。同時,有必要跟上mysql(dbms)的發展步伐,加入新的特性的支持,以及適應mysql(dbms)以后的版本。所以誕生了mysqli.dll

mysqli.dll的特性:

-可以和mysql.dll一樣的方式使用
-支持oo接口,簡簡單單調用
-支持mysql4。1引入的新特性
-通過mysqli_init() 等相關函數,可以設置高級連接選項

mysqli的使用例子:

1.和以前mysql.dll一樣的方法:

<?php

/* connect to a mysql server */
$link = mysqli_connect(
'localhost', /* the host to connect to */
'user', /* the user to connect as */
'password', /* the password to use */
'world'); /* the default table to query */

if (!$link) {
printf("can't connect to mysql server. errorcode: %sn", mysqli_connect_error());
exit;
}

/* send a query to the server */
if ($result = mysqli_query($link, 'select name, population from city order by population desc limit 5')) {

print("very large cities are:n");

/* fetch the results of the query */
while( $row = mysqli_fetch_assoc($result) ){
printf("%s (%s)n", $row['name'], $row['population']);
}

/* destroy the result set and free the memory used for it */
mysqli_free_result($result);
}

/* close the connection */
mysqli_close($link);
?>


輸出結果:

very large cities are:

mumbai (bombay) (10500000)
seoul (9981619)
s&atilde;o paulo (9968485)
shanghai (9696300)
jakarta (9604900)



2.使用內置oo接口方式調用:

<?php

/* connect to a mysql server */
$mysqli = new mysqli('localhost', 'user', 'password', 'world');

if (mysqli_connect_errno()) {
printf("can't connect to mysql server. errorcode: %sn", mysqli_connect_error());
exit;
}

/* send a query to the server */
if ($result = $mysqli->query('select name, population from city order by population desc limit 5')) {

print("very large cities are:n");

/* fetch the results of the query */
while( $row = $result->fetch_assoc() ){
printf("%s (%s)n", $row['name'], $row['population']);
}

/* destroy the result set and free the memory used for it */
$result->close();
}

/* close the connection */
$mysqli->close();
?>


支持的新特性還有:bound parameters,bound results等。。。
有興趣的可以直接去參看原英文:
http://www.zend.com/php5/articles/php5-mysqli.php#fn3

注:感覺這個不是對所有人都有用。不過。。。相信可以幫助大家多了解些“變化”,能更好的把握“趨勢” 8-)


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 蒲江县| 施秉县| 新巴尔虎右旗| 天长市| 娱乐| 迭部县| 囊谦县| 镇平县| 南郑县| 阿鲁科尔沁旗| 神池县| 光泽县| 淳化县| 云阳县| 甘孜| 滦南县| 沈阳市| 苗栗县| 正镶白旗| SHOW| 仁寿县| 城市| 乐安县| 古浪县| 湖州市| 赞皇县| 务川| 工布江达县| 南华县| 和顺县| 万荣县| 巴彦淖尔市| 观塘区| 拉萨市| 尼玛县| 平谷区| 临海市| 新宁县| 蓬安县| 新干县| 连城县|