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

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

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

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

    PHP調用三種數據庫的方法

    發布: 2007-9-07 19:19 | 作者: Paladin | 來源: eNet論壇 | 查看: 12次 | 進入軟件測試論壇討論

    領測軟件測試網 相信大家對PHP已經很熟悉了。PHP內置了幾乎對世界上所有的數據庫的支持,而不再需要重新擴充。所以有人說:不會用PHP調用數據庫,等于沒學PHP。下面是筆者根據本人的操作經驗和大俠們的意見而得出的總結,希望能給初學者提供一些益處。


    Oracle(甲骨文)是世界上最為流行的關系數據庫。它是大公司推崇的工業化的強有力的引擎。我們先看看其相關的函數:

    (1)integer ora_logon(string user , string password)

    開始對一個Oracle數據庫服務器的連接。

    (2)integer ora_open(integer connection)

    打開給出的連接的游標。

    (3)integer ora_do(integer connection, string query)

    在給出的連接上執行查詢。PHP生成一個指示器,解析查詢,并執行之。

    (4)integer ora_parse(integer cursor, string query)

    解析一個查詢并準備好執行。

    (5)boolean ora_exec(integer cursor)

    執行一個先前由ora_parse函數解析過的查詢。

    (6)boolean ora_fetch(integer cursor)

    此函數會使得一個執行過的查詢中的行被取到指示器中。這使得您可以調用ora_getcolumn函數。

    (7)string ora_getcolumn(integer cursor, integer column)

    返回當前的值。列由零開始的數字索引。

    (8)boolean ora_logoff(integer connection)

    斷開對數據庫服務器的鏈接。

    以下是向ORACLE數據庫插入數據的示例程序:

    〈html〉

    〈head〉〈title〉向ORACLE數據庫中插入數據〈/title〉〈/head〉

    〈body〉

    〈form action="〈?echo $PHP_SELF;?〉" method="post"〉

    〈table border="1" cellspacing="0" cellpadding="0"〉

    〈tr〉

    〈th〉ID〈/th〉

    〈th〉name〈/th〉

    〈th〉Description〈/th〉

    〈/tr〉

    〈tr〉

    〈td〉〈input type="text" name="name" maxlength="50" size="10"〉〈/td〉

    〈td〉〈input type="text" name="email" maxlength="255" size="30"〉〈/td〉

    〈td〉〈input type="text" name="Description" maxlength="255" size="50"〉〈/td〉

    〈/tr〉

    〈tr align="center"〉

    〈td colspan="3"〉〈input type="submit" value="提交"〉 〈input type="reset" value="重寫"〉〈/td〉

    〈/tr〉

    〈/table〉

    〈/form〉

    〈?

    //先設置兩個環境變量ORACLE_HOME,ORACLE_SID

    putenv("ORACLE_HOME=/oracle/app/oracle/product/8.0.4");

    putenv("ORACLE_SID=ora8");

    //設置網頁顯示中文

    putenv("NLS_LANG=Simplified_Chinese.zhs16cgb231280");

    if($connection=ora_logon("scott","tiger")) {

    //庫表test有ID,name,Description三項

    $sql = 'insert into test(ID,name,Description) values ';

    $sql .= '('' . $ID . '','' . $name . '',''. $Description . '')';

    if($cursor=ora_do($connect,$sql)) {

    print("insert finished!");

    }

    $query = 'select * from test';

    if($cursor=ora_do($connect,$query)) {

    ora_fetch($cursor);

    $content0=ora_getcolumn($cursor,0);

    $content1=ora_getcolumn($cursor,1);

    $content2=ora_getcolumn($cursor,2);

    print("$content0");

    print("$content1");

    print("$content2");

    ora_close($cursor);

    }

    ora_logoff($connection);

    }

    ?〉

    〈/body〉

    〈/html

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


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