Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP with Oledb

Tags:

php

oledb

Can I use PHP with Oledb connection?

As far as I know database connection as provided by PHP extension are all odbc.

like image 635
Graviton Avatar asked Jul 09 '09 01:07

Graviton


People also ask

What is the difference between Adodb Oledb and ADO Net?

You can also use OLEDB directly to connect to Sql Server but the API is messier as compared to a adodb connection which is optimized to work with Sql Server and MS Access. ADO.Net is a . Net based db connection "architecture". In ADO.Net there's a library for Oledb - System.

What is Oledb connection used for?

Object Linking and Embedding Database (OLE DB) is a connectivity method similar to Open Database Connectivity (ODBC) and uses the same core application programming interface (API) to help bridge communication between client applications and a variety of data sources.

What is Oledb in Ado net?

OLE DB stands for Object Linking and Embedding, Database. It is an API designed by Microsoft, that allows users to access a variety of data sources in a uniform manner.


1 Answers

You can use ActiveX Data Objects (Microsoft's OLEDB ActiveX layer) in PHP-Win without any third party extension as such:

$conn = new COM("ADODB.Connection") or die("Cannot start ADO"); 

// Microsoft Access connection string.
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\inetpub\wwwroot\php\mydb.mdb");

// SQL statement to build recordset.
$rs = $conn->Execute("SELECT myfield FROM mytable");
echo "<p>Below is a list of values in the MYDB.MDB database, MYABLE table, MYFIELD field.</p>";

// Display all the values in the records set
while (!$rs->EOF) { 
    $fv = $rs->Fields("myfield");
    echo "Value: ".$fv->value."<br>\n";
    $rs->MoveNext();
} 
$rs->Close(); 
like image 88
Andrew Moore Avatar answered Sep 19 '22 10:09

Andrew Moore