include('adodb5/adodb.inc.php');
$myServer = "localhost";
$myUser = "root";
$myPass = "root";
$myDB = "database";
//create an instance of the ADO connection object
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
//define connection string, specify database driver
$connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB;
$conn->open($connStr); //Open the connection to the database
这是我第一次遇到 ADODB 库,据说它会帮助我从 MySQL 切换到 Microsoft SQL Server。有谁知道为什么我会收到此错误,或者是否有一种更简单的方法,不涉及使用 php.ini 文件?
最佳答案
如果您想使用以下代码:
new COM("ADODB.Connection")
您需要在 PHP 中启用“COM 支持”,例如使用 com_dotnet 扩展 (php_com_dotnet.dll) How to install COM extension
关于php - fatal error : Class 'COM' not found whilst trying to use ADODB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/231226/