Author: John Lim.
Translation: znsoft( znsoftm@)
PHP4 already supports Microsoft's COM technology. However, the COM part is mentioned very little in the document.
Here are a few examples I've tried. Hope these give you some concepts. Note that these can only run on 32-bit Microsoft Windows platforms.
Activate ADO with php
ADO is Microsoft's database object technology. ADO includes objects connecting to the database, recordset objects that return data from query statements, and field objects that represent data elements.
Many databases do not directly support ADO. Instead, many databases support lower-level Microsoft database technologies: ODBC and OLEDB. Many databases support ODBC; but OLEDB has a reputation for being faster than ODBC.
ADO is an API that wraps ODBC and OLEDB.
This example opens a new ADO connection object, opens a traditional ACCESS database to ODBC, and then executes a SQL query, which will return a record set object. Then we display the first three fields of the record set.
<?
$dbc = new COM("");
$dbc->Provider = "MSDASQL";
$dbc->Open("nwind");
$rs = $dbc->Execute("select * from products");
$i = 0;
while (!$rs->EOF) {
$i += 1;
$fld0 = $rs->Fields(0);
$fld1 = $rs->Fields(1);
$fld2 = $rs->Fields(2);
print "$fld0->value $fld1->value $fld2->value<BR>";
$rs->MoveNext();
}
$rs->Close();
?>
Call Microsoft Word with PHP
Here is another example:
<?
$word=new COM("") or die("Cannot start Microsoft Word");
print "Loaded word version ($word->Version)\n";
$word->visible = 1 ;
$word->Documents->Add();
$word->Selection->Typetext("This is a test");
?>
Translation: znsoft( znsoftm@)
PHP4 already supports Microsoft's COM technology. However, the COM part is mentioned very little in the document.
Here are a few examples I've tried. Hope these give you some concepts. Note that these can only run on 32-bit Microsoft Windows platforms.
Activate ADO with php
ADO is Microsoft's database object technology. ADO includes objects connecting to the database, recordset objects that return data from query statements, and field objects that represent data elements.
Many databases do not directly support ADO. Instead, many databases support lower-level Microsoft database technologies: ODBC and OLEDB. Many databases support ODBC; but OLEDB has a reputation for being faster than ODBC.
ADO is an API that wraps ODBC and OLEDB.
This example opens a new ADO connection object, opens a traditional ACCESS database to ODBC, and then executes a SQL query, which will return a record set object. Then we display the first three fields of the record set.
<?
$dbc = new COM("");
$dbc->Provider = "MSDASQL";
$dbc->Open("nwind");
$rs = $dbc->Execute("select * from products");
$i = 0;
while (!$rs->EOF) {
$i += 1;
$fld0 = $rs->Fields(0);
$fld1 = $rs->Fields(1);
$fld2 = $rs->Fields(2);
print "$fld0->value $fld1->value $fld2->value<BR>";
$rs->MoveNext();
}
$rs->Close();
?>
Call Microsoft Word with PHP
Here is another example:
<?
$word=new COM("") or die("Cannot start Microsoft Word");
print "Loaded word version ($word->Version)\n";
$word->visible = 1 ;
$word->Documents->Add();
$word->Selection->Typetext("This is a test");
?>