|
|
|
COM functions are only available on the Windows version of PHP. In order to run this
script you should have com.allow_dcom has to be set to TRUE in php.ini. Through
these functions you can access any window application object. In this tutorial we
would access a MS-ACCESS database with ADODB object. Create a new .MDB file and name
it as COMDEMO. Create a New table TBCOM and then create two text fields SITE and
SITEDESC. Insert two or three entries manually. To create a new COM object use
syntax :
<?
$obj = new COM("server.object")
?>
Step : 1 ::: Setting the connection string
==========================================
<?
$connstr="Provider=Microsoft.jet.oledb.3.51;" . "Persist Security
info=false;" . "data
source=" . "comdemo.mdb" . ";";
?>
Step : 2 ::: Create the connection object and open it.
======================================================
<?
$adoconn=new COM("adodb.connection") or die("can not start Active X Data Objects");
$adoconn->Open($connstr);
?>
Step : 3 ::: Find recordset
===========================
<?
$recordset = $adoconn->Execute("select * from tbcom");
?>
Step : 4 ::: Get the total no of fields and place them in an array.
===================================================================
<?
$total_f=$recordset->fields->count();
echo "\n" . "Total No of fields : " . $total_f;
//Loop through and get name of fields.
$fld=array();
for ($i=0; $i < $total_f; $i++)
{
$fld[$i] = $recordset->Fields($i);
}
echo "<br>";
?>
Step : 5 ::: Loop through the recordset to get fields value.
============================================================
<?
$rowcnt = 0;
while (!$recordset->EOF)
{
for ($i=0; $i < $total_f; $i++)
{
echo $fld[$i]->value . " | ";
}
echo "<br>";
$rowcnt++;
$recordset->MoveNext();
?>
Step : 6 :: Close and release the objects.
==========================================
<?
$recordset->Close();
$adoconn->Close();
$recordset->Release();
$adoconn->Release();
$recordset = null;
$adoconn = null;
?>
|
|
| MS Word Mail Merge Automation (COM) Categories : PHP, PHP Classes, COM | | | com_get -- Gets the value of a COM Component's property Categories : PHP, PHP Functions, COM | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | PHP-PDF-Converter Categories : PHP, Excel, PDF, Microsoft Word, COM | | | Retrieve text from table and email to your e-
address in pipe delimited format. Categories : PHP, MySQL | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | A PHP function to encrypt and decrypt a number or string or a combination of the two. Categories : PHP, Encryption, Security | | | Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate. Categories : Authentication, PHP | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Authorize.net AIM Interface Class v1.0.0 Categories : PHP, PHP Classes, Ecommerce, Payment Gateways | | | Cut your MySQL Connections to 1 line of code Categories : PHP, Beginner Guides, Databases, MySQL | | | A simple class with some HTML output functions that would come in handy for consistent page layout etc. Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation | | | readline -- Reads a line Categories : PHP, PHP Functions, Readline | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | | | Math operations on big numbers Categories : PHP, Math. | |
| | | | lera zubkova wrote :902
I tried to use COM object, but haven`t success :(
I have some distribudet DLL, written in VB and compiled as COM. Then I write script:
$obj = new COM("dllName.appName");
and every time I have windows error: "the memory could not be read"
If you have experience in using COM in PHP, please may be you can help me :)
10q!
(P.S. I have php 4.3.0, Apache and Windows 2000)
| |
|
|
|