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

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

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

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

    Using COM with PHP

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

    領測軟件測試網 PHP4 on Windows has been extended to support Microsoft's COM technology. However documentation on the COM functions is very sparse at the moment.

    Here are some examples of stuff I have tried. Hope this gives you some ideas. Note that these only work when you are running PHP on a Windows Web server.


    Active Data Objects (ADO) with PHP
    ADO is Microsoft's database object technology. There are objects for connecting to databases, recordsets for data returned from queries, and field objects representing data elements.

    Most databases do not support ADO directly. Instead most databases support 2 lower level Microsoft database technologies: ODBC and OLEDB. More databases support ODBC; but OLEDB has a reputation of being faster than ODBC.

    ADO is then an API wrapper around ODBC and OLEDB.

    This example opens a new ADO Connection object, opens the traditional NorthWind MS-Access database via ODBC. When we execute the SQL, a RecordSet object is returned. We then display the first 3 fields of the record-set.


    <?
        $dbc = new COM("ADODB.Connection");
        $dbc->Provider = "MSDASQL";
        $dbc->Open("nwind");
        $rs = $dbc->Execute("select * from products");
        $i = 0;
        $fld0 = $rs->Fields(0);
        $fld1 = $rs->Fields(1);
        $fld2 = $rs->Fields(2);
        while (!$rs->EOF) {
            $i += 1;
            print "$fld0->value $fld1->value $fld2->value<BR>";
            $rs->MoveNext(); /*updates fld0, fld1, fld2 !*/
        }
        $rs->Close();
    ?>

    The equivalent of PHP's print $fld0->value in VBScript is Response.Write( rs.Fields(0).value ); or more concisely Response.Write( rs(0) ) because the default collection of a recordset (rs) is Fields and default property of a Field element is value.

    PHP does not support default collections and properties, so we have to write everything explicitly.


    Invoking Microsoft Word with PHP
    Here is another example.

    <?
    $word=new COM("word.application") or die("Cannot start MS Word");
    print "Loaded word version ($word->Version)\n";
    $word->visible = 1 ;
    $word->Documents->Add();
    $word->Selection->Typetext("This is a test");
    ?>

    Word's COM object model documentation is available in the online help, but it is not in the default installation. Go to the MS Office installer, select VBScript Documentation in options and you will be ready to have some fun!


    PHP COM Bugs
    While testing ADO, I hit this bug with PHP 4.02. It seems that passing a COM object as a parameter to a second COM object fails.


    <?
    $dbc = new COM('ADODB.Connection');
    $dbc->Provider = 'MSDASQL';
    $dbc->Open('NWIND'); // standard sample access database northwind
    $rs = new COM("ADODB.Recordset");

    /* The following line fails with an INVOKE error */
    /* because we are passing $dbc to $rs            */
    $rs->Open('select * from product',$dbc,3); // 3 = static cursor
    ?>

    Another bug is that the data types null and currency are not supported.

    3 Jan 2001: None of the above bugs have been fixed in PHP 4.0.4. Do we have any COM C++ experts who could fix the bugs? PHP is open source after all. 

    延伸閱讀

    文章來源于領測軟件測試網 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>