PHP4 on Windows has been extended to support Microsoft ' s COM technology. However documentation on the COM functions was very sparse at the moment.
Here are some examples of stuff I have tried. Hope This gives for you some ideas. Note This is work when you are running PHP on a Windows Web server.
Active Data Objects (ADO) with PHP
The ADO is Microsoft ' s database object technology. There are objects for connecting to databases, recordsets for data returned from queries, and Field objects representing D ATA elements.
Most databases does not support ADO directly. Instead most databases support 2 lower level Microsoft database Technologies:odbc and OLE DB. more databases support ODBC; But OLE DB has a reputation of being faster than ODBC.
The ADO is then an API wrapper around ODBC and OLE DB.
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 fields of the the Record-set.
The equivalent of PHP ' s print $fld 0->value in VBScript is Response.Write (Rs. Fields (0). value); or more concisely Response.Write (RS (0)) because the default collection to a Recordset (RS) is Fields and default Propert Y 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
This 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 to the online help, but it isn't in the default installation. Go to the MS Office installer, select VBScript documentation into options and you are ready to have some fun!
PHP COM Bugs
While testing ADO, I hit the 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 this the data types null and currency are not supported.
3 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? The PHP is open source has all.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.