PHP uses COM objects to access SQL Server, access_php basics
Source: Internet
Author: User
PHP4.0.6 above you can access COM and DCOM objects in the Win32 platform. Here borrow the ASP idea to visit SQL Server. Of course you can also use the MSSQL series functions. If it is an ASP coder, you will find the following code very familiar, habit----without him, but PHP Changl ~_~:
<?php
Author:erquan
Date:2003-3-4
City: Zhengzhou
$dbConn =new COM ("ADODB. Connection ") or Die (" Create COM Failed ");
$ADO = "Provider=sqloledb;data source=localhost;initial catalog=mytest; User Id=sa; Password=sa; ";
Access such as: $ADO = "Driver={microsoft access DRIVER (*.mdb)}; Dbq= ". Realpath ("Mydb.mdb");
$dbConn->open ($ADO);
if ($dbConn) echo "Create conn OK";
$rs =new COM ("ADODB. RecordSet ") or Die (" Create RS failed ");
echo "<br>";
if ($rs) echo "Create Rs OK";
$sql = "SELECT * from Tb_bs";
$rs->open ($sql, $dbConn, 1, 1);
How is it, it's easy? For ASP coder, if suddenly your boss received a list of PHP projects, you do not have to panic, spend a little time you can also successfully developed ~
Accessing SQL Server's stored procedures is almost the same as the ASP's approach.
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.