• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    簡單介紹下 PHP5 中引入的 MYSQLI

    發布: 2007-7-14 19:53 | 作者: 佚名    | 來源: 網絡轉載     | 查看: 14次 | 進入軟件測試論壇討論

    領測軟件測試網


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

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

    Click to fullsize


    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 */
    上一篇      目錄      下一篇 = 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 (!上一篇      目錄      下一篇) {
    printf(&quot;Can't connect to MySQL Server. Errorcode: %sn&quot;, 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(&quot;Very large cities are:n&quot;);

    /* Fetch the results of the query */
    while( $row = mysqli_fetch_assoc($result) ){
    printf(&quot;%s (%s)n&quot;, $row['Name'], $row['Population']);
    }

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

    /* Close the connection */
    mysqli_close(上一篇      目錄      下一篇);
    ?>



    輸出結果:
    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(&quot;Can't connect to MySQL Server. Errorcode: %sn&quot;, 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(&quot;Very large cities are:n&quot;);

    /* Fetch the results of the query */
    while( $row = $result->fetch_assoc() ){
    printf(&quot;%s (%s)n&quot;, $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-)

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>